How to copy files from VM to Azure storage account with same last modified date using AZ copy

Mahasiva, Ravi (CSW) 60 Reputation points
2024-06-25T10:24:23.7866667+00:00

Hi Team,

we are copying files from vm to azure storage account, we have installed AZ copy there, we want to copy last modified date from vm to storage account, could you please help us on that.

we have used below synatx
azcopy copy "\local\path" "https://myaccount.blob.core.windows.net/mycontainer" --recursive=true --set-content-type=true --set-content-disposition=true
and one more method
-preserve-last-modified-time
but not working please tell for any alternate solution

Azure Storage Accounts
Azure Storage Accounts
Globally unique resources that provide access to data management services and serve as the parent namespace for the services.
2,863 questions
0 comments No comments
{count} votes

1 answer

Sort by: Most helpful
  1. Sumarigo-MSFT 44,891 Reputation points Microsoft Employee
    2024-06-25T14:30:25.68+00:00

    @Mahasiva, Ravi (CSW) Welcome to Microsoft Q&A Forum, Thank you for posting your query here!

    Which version on Azcopy are you using?

    If you are still having issues preserving the last modified time of the files, you may want to check the file system on the VM to make sure that it supports last modified time, and check the destination container in the Azure Storage account .

    Looking at the "azcopy copy" and "azcopy sync" commands, they support using wildcard patterns to filter files based on the names/paths of files. The wildcard patterns normally can be used to filter the files which have the similar format of name/path.

    Since the names of your files have the same format and the latest filename is dynamically generated with the date-time, it is hard to filter the last file version based on the filename

    You might try to use the "azcopy list" to check whether it can return the created date (or latest modified date) of each backup file, then try to compare the dates between file versions to get the latest file version.

    To copy files changed before or after the AzCopy job has started, AzCopy provides date and time in the job log in ISO8601 format (search for 'ISO 8601 START TIME' in the job log) that can be used with the --include-after and --include-before flags, see examples below. This is helpful for incremental copies.

    Upload files that were modified after a date and time and Download files that were modified after a date and time is available in this article

    Additional information: You can try robocopy: (you need to use the /COPY and /DCOPY options to preserve the timestamps. Good discussion on this can be found on this thread.)

    Please let us know if you have any further queries. I’m happy to assist you further.     


    Please do not forget to "Accept the answer” and “up-vote” wherever the information provided helps you, this can be beneficial to other community members.

    0 comments No comments