What is File-Snapshot Backup?

In order to fully understand File-Snapshot backup we first need to get an understanding of Azure blob snapshots. An Azure blob snapshot is a read-only version of a blob taken at a point in time. As data in the blob changes over time, the snapshots continue to point to the data at the time when the snapshots were created.

File-Snapshot backup consists of a set of Azure blob snapshots and a SQL backup file that contains pointers to those snapshots.

There are two types of File-Snapshot backups, full database backups and transaction log backups.

A full database backup creates a snapshot of each data and log file comprising the database and establishes the transaction log backup chain. Unlike tradition backups, a File-Snapshot backup does not copy all of the data in the database, it instead relies on the Azure storage service to snapshot the files. This makes the backup process extremely fast.

A transaction log backup creates a snapshot of each database file, records the location of the snapshots in the backup (.bak) file, and truncates the transaction log file. This is unlike traditional transaction log backups where only the transaction log file is captured in the backup.

How do I use File-Snapshot Backup?

The first thing you will need to do is set the recovery model to full and establish the transaction log backup chain with a full backup using File-Snapshot. Below is an example of setting the recovery model to full and creating the first full backup of the database.

— To set the recovery model to full.USE master;GOALTER DATABASE [MY_DATABASE_NAME]SET RECOVERY FULL;GO— Create a full backup of the database.BACKUP DATABASE [MY_DATABASE_NAME] TO URL = 'https://<mystorageaccountname>.blob.core.windows.net/<mycontainername>/<mydatabasename>.bak'WITH FILE_SNAPSHOT;GO

This full backup will create a snapshot of each data and log file, create a backup file with pointers to the snapshots, and establish the transaction log backup chain.

After the initial full backup, you only need to perform transaction log backups because each transaction log File-Snapshot backup set contains blob snapshots of all database files and can be used to perform a database restore or a log restore. Below is an example of creating a transaction log backup and appending the time to the file name.

The capability of transaction log File-Snapshot backups to be used for a database restore eliminates the need for additional full or differential backups. This greatly simplifies your backup plan.

How do I restore File-Snapshot Backups?

With File-Snapshot backup you can restore to the end of a backup, or you can restore to a specific point in time. For both of these restore options you can use restore and replace or restore and move to a new database.

For restoring to the end of a backup you only need the File-Snapshot backup you want to restore to the end of. This will work for both full backups and transaction log backups. Below demonstrates restoring to the end of a transaction log File-Snapshot backup to a new database.

For restoring to a specific point in time, you will need the File-Snapshot backup before the point in time and the File-Snapshot backup after the point in time. Below demonstrates to restoring to May 18th, 2015 at 5:35 pm using two transaction log File-Snapshot backups overwriting the original database.

Unlike traditional point in time restore, where you need all the transaction log backups from the most recent full or differential backup before the point in time, File-Snapshot backup only requires the backup before the point in time, and the backup after the point in time. The image below illustrates what is required to restore to a place in the last log backup of a backup chain using traditional streaming backup versus using File-Snapshot backup. Note that difference in the number of backups required for File-Snapshot backup.

So really, how fast is it?

In the File-Snapshot Backup Channel 9 Video, the performance of point in time restore with File-Snapshot backup vs traditional streaming backup was compared. The demo environment consisted of the following:

SQL Server running on a D13 VM in Azure with 8 CPU cores and 56 GB of memory.

Database with 10 data files and one log file, all stored in Azure blob storage.

A 1 GB table with three columns; int, datetime2, and binary(4000)Next, 3.5 GB of data was generated over a two-hour period with log backups being take every 20 minutes. A point in time in the last (6th) backup file was restored to.

With traditional streaming backup the restore took over 30 minutes, while with File-Snapshot backup the restore took less than one minute. In this example, point in time restore with File-Snapshot was over 30x faster than traditional streaming backup.