I want to use AzCopy within an Azure CLI task within an Azure DevOps pipeline to copy the most recent version of a backup file from one storage account to another, what is the best method for doing this?
For context, the folder the files sit in keeps the last 5 days of backups and their filenames are appended with the date and time they were taken. It therefore needs to be dynamic, I cant simply request for a particular file name.
Tried consulting microsofts documentation regarding the 'Get-AzStorageBlob' function, but there is no mention of this as a use case, nor can I find anything helpful online.
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.