The Back up and Restore feature in Azure App Service lets you easily create app backups manually or on a schedule. 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 backup the followin 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:
- SQL Database
- Azure Database for MySQL (Preview)
- Azure Database for PostgreSQL (Preview)
- ClearDB MySQL
- MySQL in-app
Each backup is a complete offline copy of your app, not an incremental update.
Requirements and restrictions
- The Back up and Restore feature requires the App Service plan to be in the Standard tier or Premium tier. For more information
about scaling your App Service plan to use a higher tier, see Scale up an app in Azure.
Premium tier allows 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 backup. For more information on Azure storage accounts, see the links at the end of this article.
- Backups can be up to 10 GB of app and database content. If the backup size exceeds this limit, you get an error .
Create a manual backup
In the Azure portal, navigate to your app's blade, select Settings, then Backups. The Backups blade is displayed.
If you see this 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 Backups blade, 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 backup. If you wish, you can create a storage account or a new container in the respective blades. When you're done, click Select.
In the Configure Backup Settings blade that is still left open, click Database Settings, then select the databases you want to include in the backups (SQL database, MySQL, or PostgreSQL), 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 blade for your app.
- In the Configure Backup Settings blade, click Save.
In the command bar of the Backups blade, click Backup Now.
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.
Configure automated backups
In the Backups blade, click Schedule: Not configured.
On the Backup Schedule Settings blade, set Scheduled Backup to On, then configure the backup schedule as desired and click OK.
In the Configure Backup Settings blade that is still left open, click Storage Settings, then 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 backup. If you wish, you can create a storage account or a new container in the respective blades. When you're done, click Select.
In the Configure Backup Settings blade, click Database Settings, then select the databases you want to include in the backups (SQL database, MySQL, or PostgreSQL), 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 blade for your app. If you are using MySQL in-app, you won't see any databases listed since the connection string is not exposed in the portal under Application settings
- In the Configure Backup Settings blade, click Save.
Configure Partial Backups
Sometimes you don't want to backup 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 backup at a time).
- You don't want to backup the log files.
Partial backups allows you choose exactly which files you want to backup.
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.
An easy way to access your files is to use Kudu . Click Adavanced Tools -> Go setting for your web app to access Kudu.
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 list above 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 blacklisted directories, or any blacklisted 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 blade 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 a SQL database, this is a BACPAC file (no file extension) and can be imported. To create a SQL database based on the BACPAC export, see Import a BACPAC File to Create a New User Database.
Altering any of the files in your websitebackups container can cause the backup to become invalid and therefore non-restorable.