I store data in Azure Storage tables and blob storage. I would like to automatically backup my data to protect against accidental data corruption by users or by a software issue. There isn't a good solution for this from Microsoft and, while there are paid solutions for automatic backups, it seems like there should be a straight-forward way to backup and restore this data.
After doing a lot of research on the best way to automatically backup data, I found that the easiest way to do this is to schedule a job in the Windows Task Scheduler on an Azure virtual machine that uses AZCopy. AZCopy does the work of moving the table data to the VM and then back out to a secondary blob store in Azure to hold the backup. The batch file also causes AZCopy to copy the blobs from the source storage account into the target account directly.
You can see a detailed description of how I made this work complete with links to the batch files that I use to automate the backup at this link: http://www.eastfive.com/2016/03/01/automated-backup-of-azure-storage-tables-and-blobs/
02/08/2018 update on this answer: I raised this question to Azure support on January 18, 2018, assuming that surely they had a way to do this now via a service in Azure. Unfortunately that is not the case and there is (according to Microsoft support) no better way to do table backups than those that existed when this question was first posed. This is the answer from support from 01/24/2018:
"I have reviewed over your case and unfortunately there is not a way to do a snapshot of an entire account or container and so the only way to do snapshots with Azure Storage is through blob iteration and applying snapshots then migrating the snaps over to a secondary account. Or you can simply copy the actual files to another account but this would have higher latency and be more costly on storage capacity, where snapshots would take up less and be quicker to transfer.
The methods we support for transfer are AzCopy and the Data Movement Library which can be used to make custom migration solutions in Java or C#.
If you wanted to automate these processes then you could do this via Powershell and Azure Automation or with Azure Functions but assistance with those solutions would likely need to be raised through another support request as my team purely supports Azure Storage."
So, there still exists no automated way to do these backups. My team is working on a library to do backups. When we have that completed, I will post back here.
05/08/2018 update on this answer: As mentioned, my team has been working on a library to automate backups. You can find the project here: https://github.com/eastfivellc/EastFive.Azure.Storage.Backup. Please feel free to contribute.
10/18/2018 update on this answer: I was able to copy data in Azure using their Azure Data Factory functionality. I used Data Factory to pipe data from my source to target storage for both tables and blobs. However, the data movement costs are exorbitantly high (in the hundreds of dollars per backup). So, this is not a solution for backups. As mentioned in my post from above (and in an answer below), the Azure Data Movement Library is the best solution here.
We wrote a .NET library that backups tables and blobs. You can easily implement this in an azure function timer trigger.
In this blog I explain how to implement it using an Azure function.
[FunctionName("Function1")]
public static async Task Run([TimerTrigger("0 */5 * * * *")]TimerInfo myTimer, ILogger log, ExecutionContext context)
{
var sourceAccountName = Environment.GetEnvironmentVariable("BackupSourceAccountName");
var sourceKey = Environment.GetEnvironmentVariable("BackupSourceAccountKey");
var backupAzureStorage = new Luminis.AzureStorageBackup.BackupAzureStorage(sourceAccountName, sourceKey, log, context.FunctionAppDirectory);
var destinationAccountName = Environment.GetEnvironmentVariable("BackupDestinationAccountName");
var destinationKey = Environment.GetEnvironmentVariable("BackupDestinationAccountKey");
var destinationContainerName = Environment.GetEnvironmentVariable("BackupDestinationContainer");
// Backup Tables
await backupAzureStorage.BackupAzureTablesToBlobStorage("table1,table2", destinationAccountName, destinationKey, destinationContainerName, "tables");
// Backup Blobs
await backupAzureStorage.BackupBlobStorage("container1,container2", destinationAccountName, destinationKey, destinationContainerName, "blobs");
}
If you are still looking for a solution for this problem, please look at a package I released on NuGet AzureTableUtilities
You can copy a table to a file or blob file, restore a table from a file or blob file as well as copy to another table on the same account or a different account. Filtering on PartitionKey and Timestamp is also available.
I also created a reference command line code base and put it on GitHub which allows this to be executed from a command line or Docker container.
Let me know if this doesn't quite match what you want, and I'll see if I can enhance the functionality. I realize the tool itself does not "automatically" back Azure Tables data up; however, using the command line example either under windows directly or in a Docker container, I think you'd be able to set up whatever process(es) you wanted to back things up.
You can also use 3rd party tools like Cerebrata Azure Management Cmdlets or the functionality Asynchronous Copy Blob announced by Microsoft Azure Storage team which will essentially allow you to copy data from one storage account to another storage account without downloading the data locally.
Check the thread for more: What is the best way to backup Azure Blob Storage contents.
Hope this helps.
Have a look at the Microsoft Azure Storage Data Movement Library
This seems to offer most of the functionality of AzCopy, but in a nuget package, so you can use it pretty much anywhere you like.
We are running this in a triggered webjob and it seems to be performing really well for both table and blob storage backup.
You can use Microsoft Azure Storage Explorer to Copy/Paste Tables, Upload/Download file systems, Blob, Cosmos, Data lake etc., its very user friendly tool.
Download Link : https://azure.microsoft.com/en-in/features/storage-explorer/
© 2022 - 2024 — McMap. All rights reserved.
azcopy.exe /Source:http://PathToYourTableStorage /Dest:C:\YourFolderPath /Key:StorageAccessKey1or2
– Moorman