Using azcopy to copy files

  • Im trying to copy the contents of my sql server backup .bak files to azure storage using azcopy.

    Im using this command in a batch .bat file -

    "C:\Program Files (x86)\Microsoft SDKs\Azure\AzCopy\AzCopy.exe" ^

    /Source:"I:\" /Dest:https://hmlrservicesstorage.****************************/ ^

    /DestKey:********************************************** /Pattern:"*.bak" /s /XO

    On the I drive there are two folders, one a normal folder and the other a network share.

    When I run the .bat file through a cmd prompt it runs fine copying all .bak files to the storage, yet when I run the same .bat file through a SQL Server gent job, using exactly the same .bat file it only copies the network share folder across and not the normal folders contents.

    I am copying from an Azure VM in the cloud to azure storage account.

    I cant understand why and would greatly appreciate any help on this.

  • I have never used the tool azcopy.exe before, but as a thought, does your SQL Server Agent account have permission to the Azure site and have access to the files on I:\ drive?

    What I would try is start the command prompt up as the SQL Server Agent account and list the contents of the I drive.

    One way to do this would be to use this  (in a bat file):

    dir /s I:\ > c:\temp\IFiles.txt

    NOTE - make the folder C:\temp prior to running that.

    Run that bat file as a SQL agent job and check the contents of the file C:\temp\IFiles.txt.  Everything it lists is everything that the SQL Server Agent account can see.

    My guess is that one or more folders on I:\ are not accessible by the SQL Server Agent account.

    The above is all just my opinion on what you should do. 
    As with all advice you find on a random internet forum - you shouldn't blindly follow it.  Always test on a test server to see if there is negative side effects before making changes to live!
    I recommend you NEVER run "random code" you found online on any system you care about UNLESS you understand and can verify the code OR you don't care if the code trashes your system.

Viewing 2 posts - 1 through 1 (of 1 total)

You must be logged in to reply to this topic. Login to reply