Hello Vaibhav Jain,
Welcome to the Microsoft Q&A and thank you for posting your questions here.
I understand that your AZCopy Sync Skipping Zero Byte Files in Azure Blob Storage.
Others have reported similar issues with 0-byte files being skipped - https://github.com/Azure/azure-storage-azcopy/issues/1291. They resolved it by using workarounds like the ones mentioned below. If you can implement these strategies, you can effectively replicate Azure Blob Storage while preserving empty folders using dummy files. Whether you adjust AZCopy configurations or incorporate complementary tools and scripts, these solutions provide practical steps to overcome the limitations of AZCopy Sync.
- To ensure that dummy files are included in the sync operation, you can use the AZCopy
--include-pattern
flag. This flag allows you to specify patterns for files that should be included in the sync process. For example using bash:
azcopy sync <source-path> <destination-path> --include-pattern "<no name>"
This command ensures that even 0-byte dummy files with the name <no name>
are included in the sync operation.
- If the
--include-pattern
flag does not work as expected and <no name>
files are still being skipped, you can use a script to preprocess these files. Convert 0-byte files to 1-byte files before syncing in bash command: find <source-path> -type f -empty -exec truncate -s 1 {} \;
After syncing, you can revert these files back to 0 bytes at the destination if necessary:
find <destination-path> -type f -exec truncate -s 0 {} \;
This approach ensures that all files, including those representing empty folders, are copied.
- Consider using Azure Data Factory or a similar ETL tool for more robust storage replication as alternative tool. These tools offer advanced options for preserving folder structures and handling 0-byte files. For instance, you can set up a Copy Data pipeline in Azure Data Factory to replicate blobs while maintaining metadata, such as folder representations.
- Another approach is to generate a metadata file before syncing. This file can explicitly instruct AZCopy to include and create folders. Use the following command to generate the metadata file using bash:
azcopy list <source-path> --recursive=true --output <metadata-file>
Then, apply this metadata during the sync to ensure all folders, represented by dummy files, are included.
I hope this is helpful! Do not hesitate to let me know if you have any other questions or need alternative solution.
Please don't forget to close up the thread here by upvoting and accept it as an answer if it is helpful.