Written by 3:50 pm Microsoft, Microsoft Azure, Windows • 6 Comments

Sync Folder with Azure Blob Storage

Synchronize Folder with Azure Blob Storage using AzCopy

With AzCopy v10 the team added a new function to sync folders with Azure Blob Storage. This is great if you have a local folder running on a server or even on a client device which you can to keep synchronized with Azure Blob storage. This will not only upload new or changed files, with the “–delete-destination” parameter you can let AzCopy remove locally deleted files on Azure blob storage and vice-versa.

First, make sure you install and set up AzCopy.

Sync Folder with Azure Blob Storage

You can use the following command to sync a local folder with Azure Blob Storage. This command will only sync changed and new files, it compares file names and last modified timestamps.

Sync Folder with Azure Blob Storage using AzCopy

 
azcopy sync "C:\Temp\images" "https://tomsaccount.blob.core.windows.net/images" --recursive

As mentioned, if you set the “–delete-destination” parameter to “true”, AzCopy deletes files without a prompt. If you want to check first, which files will be removed, before AzCopy deletes a file, set the –delete-destination flag to “prompt”.

To make sure you are not accidentally are deleting data, make sure to enable the soft delete feature before you use the –delete-destination parameter.

Synchronize Folder with Azure Blob Storage using AzCopy

I deleted the file “3.jpg” locally and I ran the azcopy sync again. You can see that file “3.jpg” was removed from the Azure Blob Storage.

Sync to a local folder

To sync Azure Blob Storage to a local folder, you can use the following command.

 
azcopy sync "https://tomsaccount.blob.core.windows.net/images" "C:\Temp\images" --recursive

As of today, the sync feature does only supports local folders with Azure Blobs. Syncing with AWS or from Storage account to Storage account is currently not supported.

I hope this gives you a quick overview of how you can sync folder with Azure Blob Storage, if you want to know more, check out the Microsoft Docs about how you can transfer data using AzCopy. If you have any questions, please let me know in the comments.

Tags: , , , , , , , , Last modified: June 4, 2019
Close Search Window
Close