Back up your app in Azure

6 min to read Contributors

The Backup and Restore feature in Azure App Service lets you easily create app backups manually or automatically. You can restore your app to a previous state, or create a new app based on one of your original app's backups.

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:

  • App configuration
  • File content
  • Any Azure SQL Databases or Azure MySQL (ClearDB) databases connected to your app (you can choose which ones to include in the backup)

This information is backed up to the Azure storage account and container that you specify.

Note

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 tier or higher. For more information about scaling your App Service plan to use a higher tier, see Scale up an app in Azure. Note that Premium tier allows a greater number of daily backups 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 the links at the end of this article.
  • Backups can be up to 10GB of app and database content. You will get an error if the backup size exceeds this limit.

Create a manual backup

  1. In the Azure Portal, navigate to your app's blade, select Settings, then Backups. The Backups blade will be displayed.

    Backups page

    Note

    If you see the message below, click it to upgrade your App Service plan before you can proceed with backups. See Scale up an app in Azure for more information.
    Choose storage account

  2. In the Backups blade, click Storage: Not configured to configure a storage account.

    Choose storage account

  3. 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 blades. When you're done, click Select.

    Choose storage account

  4. 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 or MySQL), then click OK.

    Choose storage account

    Note

    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.

  5. In the Configure Backup Settings blade, click Save.
  6. In the command bar of the Backups blade, click Backup Now.

    BackUpNow button

    You will see a progress message during the backup process.

After you have configured a storage account and container for backups, you can make a manual backup at any time.

Configure automated backups

  1. In the Backups blade, click Schedule: Not configured.

    Choose storage account

  2. On the Backup Schedule Settings blade, set Scheduled Backup to On, then configure the backup schedule as desired and click OK.

    Enable automated backups

  3. 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 back up. If you wish, you can create a new storage account or a new container in the respective blades. When you're done, click Select.

    Choose storage account

  4. In the Configure Backup Settings blade, click Database Settings, then select the databases you want to include in the backups (SQL database or MySQL), then click OK.

    Choose storage account

    Note

    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.

  5. In the Configure Backup Settings blade, click Save.

Backup just part of your app

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 10GB of content (that's the max amount you can backup at a time).
  • You don't want to back up the log files.

Partial backups will let you choose exactly which files you want to back up.

Exclude files from your backup

To exclude files and folders from your backups, create a _backup.filter file in the D:\home\site\wwwroot folder of your app and specify the list of files and folders you want to exclude in there. An easy way to access this is through the Kudu Console.

Suppose you have an app that contains log files and static images from past years that are never going to change. You already have a full backup of the app that includes the old images. Now you want to backup the app every day, but you don't want to pay for storing log files or the static image files that never change.

Logs Folder Images Folder

The below steps show how you would exclude these files from the backup.

  1. Go to http://{yourapp}.scm.azurewebsites.net/DebugConsole and identify the folders that you want to exclude from your backups. In this example, you would want to exclude the following files and folders shown in that UI:

     D:\home\site\wwwroot\Logs
     D:\home\LogFiles
     D:\home\site\wwwroot\Images\2013
     D:\home\site\wwwroot\Images\2014
     D:\home\site\wwwroot\Images\brand.png
    

    [AZURE.NOTE] The last line shows that you can exclude individuals files as well as folders.

  2. 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\Logs \LogFiles \site\wwwroot\Images\2013 \site\wwwroot\Images\2014 \site\wwwroot\Images\brand.png

  3. Upload this 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 in http://{yourapp}.scm.azurewebsites.net/DebugConsole and insert the content there.
  4. Run backups the same way you would normally do it, manually or automatically.

Now, any files and folders that are specified in _backup.filter will be excluded from the backup. In this example, the log files and the 2013 and 2014 image files will no longer be backed up, as well as brand.png.

Note

You restore partial backups of your site the same way you would restore a regular backup. The restore process will do 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 will be visible on the Containers blade of your storage account, as well as 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 new SQL database based on the BACPAC export, see Import a BACPAC File to Create a New User Database.

Warning

Altering any of the files in your websitebackups container can cause the backup to become invalid and therefore non-restorable.

Next Steps

For information on restoring an app from a backup, see Restore an app in Azure. You can also backup and restore App Service apps using REST API (see Use REST to back up and restore App Service apps).

Note

If you want to get started with Azure App Service before signing up for an Azure account, go to Try App Service, where you can immediately create a short-lived starter web app in App Service. No credit cards required; no commitments.