Back up your app in Azure
The Backup and Restore feature in Azure App Service lets you easily create app backups manually or on a schedule. You can configure the backups to be retained up to an indefinite amount of time. You can restore the app to a snapshot of a previous state by overwriting the existing app or restoring to another app.
For information on restoring an app from backup, see Restore an app in Azure.
What gets backed up
App Service can back up the following information to an Azure storage account and container that you have configured your app to use.
- App configuration
- File content
- Database connected to your app
The following database solutions are supported with backup feature:
Each backup is a complete offline copy of your app, not an incremental update.
Requirements and restrictions
- The Backup and Restore feature requires the App Service plan to be in the Standard, Premium or Isolated tier. For more information about scaling your App Service plan to use a higher tier, see Scale up an app in Azure. Premium and Isolated tiers allow a greater number of daily back ups than Standard tier.
- You need an Azure storage account and container in the same subscription as the app that you want to back up. For more information on Azure storage accounts, see Azure storage account overview.
- Backups can be up to 10 GB of app and database content. If the backup size exceeds this limit, you get an error.
- Backups of TLS enabled Azure Database for MySQL is not supported. If a backup is configured, you will encounter backup failures.
- Backups of TLS enabled Azure Database for PostgreSQL is not supported. If a backup is configured, you will encounter backup failures.
- In-app MySQL databases are automatically backed up without any configuration. If you make manually settings for in-app MySQL databases, such as adding connection strings, the backups may not work correctly.
- Using a firewall enabled storage account as the destination for your backups is not supported. If a backup is configured, you will encounter backup failures.
Create a manual backup
In the Azure portal, navigate to your app's page, select Backups. The Backups page is displayed.
If you see the following message, click it to upgrade your App Service plan before you can proceed with backups. For more information, see Scale up an app in Azure.
In the Backup page, select Backup is not configured. Click here to configure backup for your app.
In the Backup Configuration page, click Storage not configured to configure a storage account.
Choose your backup destination by selecting a Storage Account and Container. The storage account must belong to the same subscription as the app you want to back up. If you wish, you can create a new storage account or a new container in the respective pages. When you're done, click Select.
In the Backup Configuration page that is still left open, you can configure Backup Database, then select the databases you want to include in the backups (SQL Database or MySQL), then click OK.
For a database to appear in this list, its connection string must exist in the Connection strings section of the Application settings page for your app.
In-app MySQL databases are automatically backed up without any configuration. If you make settings for in-app MySQL databases manually, such as adding connection strings, the backups may not work correctly.
In the Backup Configuration page, click Save.
In the Backups page, click Backup.
You see a progress message during the backup process.
Once the storage account and container is configured, you can initiate a manual backup at any time. Manual backups are retained indefinitely.
Configure automated backups
In the Backup Configuration page, set Scheduled backup to On.
Configure the backup schedule as desired and select OK.
Configure Partial Backups
Sometimes you don't want to back up everything on your app. Here are a few examples:
- You set up weekly backups of your app that contains static content that never changes, such as old blog posts or images.
- Your app has over 10 GB of content (that's the max amount you can back up at a time).
- You don't want to back up the log files.
Partial backups allow you choose exactly which files you want to back up.
Individual databases in the backup can be 4GB max but the total max size of the backup is 10GB
Exclude files from your backup
Suppose you have an app that contains log files and static images that have been backup once and are not going to change. In such cases, you can exclude those folders and files from being stored in your future backups. To exclude files and folders from your backups, create a
_backup.filter file in the
D:\home\site\wwwroot folder of your app. Specify the list of files and folders you want to exclude in this file.
You can access your files by navigating to
https://<app-name>.scm.azurewebsites.net/DebugConsole. If prompted, sign in to your Azure account.
Identify the folders that you want to exclude from your backups. For example, you want to filter out the highlighted folder and files.
Create a file called
_backup.filter and put the preceding list in the file, but remove
D:\home. List one directory or file per line. So the content of the file should be:
\site\wwwroot\Images\brand.png \site\wwwroot\Images\2014 \site\wwwroot\Images\2013
_backup.filter file to the
D:\home\site\wwwroot\ directory of your site using ftp or any other method. If you wish, you can create the file directly using Kudu
DebugConsole and insert the content there.
Run backups the same way you would normally do it, manually or automatically. Now, any files and folders that are specified in
_backup.filter is excluded from the future backups scheduled or manually initiated.
You restore partial backups of your site the same way you would restore a regular backup. The restore process does the right thing.
When a full backup is restored, all content on the site is replaced with whatever is in the backup. If a file is on the site, but not in the backup it gets deleted. But when a partial backup is restored, any content that is located in one of the restricted directories, or any restricted file, is left as is.
How backups are stored
After you have made one or more backups for your app, the backups are visible on the Containers page of your storage account, and your app. In the storage account, each backup consists of a
.zip file that contains the backup data and an
.xml file that contains a manifest of the
.zip file contents. You can unzip and browse these files if you want to access your backups without actually performing an app restore.
The database backup for the app is stored in the root of the .zip file. For SQL Database, this is a BACPAC file (no file extension) and can be imported. To create a database in Azure SQL Database based on the BACPAC export, see Import a BACPAC file to create a database in Azure SQL Database.
Altering any of the files in your websitebackups container can cause the backup to become invalid and therefore non-restorable.
Automate with scripts
For samples, see:
For information on restoring an app from a backup, see Restore an app in Azure.