AZCopy sync, synchronize your local directory with an Azure Container (SAS)

12 Apr 2021 2324 views 0 minutes to read Contributors

Documentation can be found here: AZCopy sync

Use AZCOPY.EXE (Download AZCopy)

azcopy sync "c:/temp/" "----here you put your SAS key -----" --recursive

The last forward slash in the first parameter is important.

Sometimes there can be a communication error which causes the AZCopy to be interrupted.

Put the following statements in a batch file so that it continues untill the job is finished. 

%1 = parameter 1 (local folder)

%2 = SAS key (provide this parameter in "--- enter here your SAS key ---") because inside the batchfile the SAS key causes problems due to preserved keywords/patterns

:startover

set HTTPS_PROXY=dummy.invalid

SET NO_PROXY=*

set AZCOPY_LOG_LOCATION=c:\temp

SET /A retries = 0

 

azcopy sync "%1" %2 --recursive

IF %ERRORLEVEL% NEQ 0 (
SET /A retries = retries + 1
IF %retries% LEQ 100 (
ECHO Trying again %retries% ...
ECHO
GOTO :startover
)
)

In this article