Azure AppService Off-Site or Remote Backups

The adoption of Azure AppService continues to grow, and I fully support this. However, one of the most common requests that I get when transitioning people surround backups and true redundancy and integrity strategies. Out of the box, Azure provides two backup options, which are important to understand. In addition to this, there are easy tools to automate off-site backups if desired.

Configuration Based Options

The following backup strategies are available with simple Azure configuration and do not require any programmatic intervention.

Azure Backups

Azure Backups are accessed directly from your App Service by navigating to the “Backups” blade and is co-mingled functionality-wise with the “Snapshot” functionality I’ll discuss later. Azure backups support a basic configuration and will back up the site on a scheduled basis, and optionally the database, to a zip archive and place it in Azure Blob Storage.

Benefits

  • Backups are placed in Blob Storage as regular zip files. They can be downloaded and with a GRS storage account can be geo-redundant
  • You can easily extract and restore single files by downloading the zip.
  • Automatic support exists for schedules and retention policies.

Limitations/Drawbacks

  • If the total backup size is larger than 10 gb, you cannot use this process at all
  • Although automatic failures are not automatically broadcast, so you must review.
  • File lock issues can prevent specific files from backing up

Snapshots

Snapshots are a feature that is currently in Preview within Azure. It has been a preview functionality for more than 2 years at this point, but it is still a preview feature. Even though they are preview they operate entirely different than the Backups functionality and provide a number of additional benefits, with a different set of limitations.

Benefits

  • No website storage limits
  • No configuration is needed, automatically implemented
  • No file copy issues due to file locks
  • Implementing using Shadow Copies so more granular restore options for time are available
  • Internally 90 days of backups are retained, for Azure Platform recovery purposes

Limitations/Drawbacks

  • Requires a Premium tier of AppService
  • Only 30 days of history is available
  • You must restore the ENTIRE application, you cannot restore a single file
  • You cannot download a snapshot to your local machine
  • It does not backup the database at the same time

Manual/Programmatic Options

After exhausting the out-of-the-box options, let’s look at a few options that we can use to quickly download a copy of the site for offline storage.

KUDU API Download

KUDU is the “Advanced Tools” interface that you can access from within your Azure AppService and it contains an API that allows you to do administrative functions in addition to the web-based interactive behavior. Using KUDU it is easy to get a full download.

If Logged In

If you are already logged in to KUDU you can simply past the following into the browser to download the entire contents of your /wwwroot folder.Downloading Zip of Website – Logged-In

https://your-site.scm.azurewebsites.net/api/zip/site/wwwroot/

If Not Logged In

If you want to do this programmatically, or via a command line, you can use the publish profile credentials and format a URL such as the following to accomplish the same single-file download.Downloading Zip of Website – Not-Logged-In

https://user:pass@your-site.scm.azurewebsites.net/api/zip/site/wwwroot/

By simply placing your username, password, and site address in, it is easy to download a copy automatically. This process works very well and leverages the functionality of KUDU to do this without cluttering your system. Obviously, retention/storage is all on you, but this is a TRUE off-site backup.

Traditional FTP

ESPC call for speakers 2024
The most common strategy used is of course the most simple, connect via FTP and download all of the files. The limitation of this method is nothing more than the time necessary to download the assets. Small sites, this is totally acceptable and works well. Larger sites, this can take hours given the number of files and/or the size of the files to download.

Powershell Zip & FTP Download

We can level up the traditional FTP model and utilize the KUDU Powershell window to Zip the site, and then download via FTP, to complete this process it is quite easy, but there are a few small nuances to consider. You start the process by accessing the Powershell Debug Console and navigating into the /site folder. You can then execute the following commands.Create Zip of Site (Powershell)

$ProgressPreference="SilentlyContinue" 
measure-command {Compress-Archive -Path .\wwwroot -DestinationPath .\Mitch-Backup}

The first statement is critical, as the KUDU console does not support progress bars, so you must set the progress preference to silentlycontinue; otherwise, the entire process will fail. The second command creates a backup file called Mitch-Backup.zip in the current directory of the entire site. You can then take this single file and download/transfer it much faster than grabbing individual files. I have wrapped the command with a measure-command to help get analytic information on how long it took to complete since we have no progress indicators available.

Selecting a Direction

There are many methods available for offsite and remote backups. The right choice, or choices, will be different for everyone depending on the risk tolerance, frequency of updates and other system needs. However, I hope that this overview gives you some insight into the options available.

This blog is part of Azure Week. Check it out for more great content!

About the Author:

Mitchel Sellers is the Founder, CEO, and Director of Development for IowaComputerGurus (ICG) and serves as one of its core technical contributors. He has personally managed hundreds of successful website and application projects, served as an adjunct technology professor at Iowa colleges, and become a published author – writing and contributing to numerous articles and three industry-standard programming texts.

Reference:

Sellers, M. (2021). Azure AppService Off-Site or Remote Backups. Available at: https://mitchelsellers.com/blog/article/azure-appservice-off-site-or-remote-backups [Accessed: 6th July 2021].

Share this on...

Rate this Post:

Share: