Why isn't azcopy cp --include-regex not matching any files?

156 Views Asked by At

I have a couple of folders in a blob container that I want to download all of the contents of. I want to download the contents based off of the name of the folders alone, so like "testA" instead of "/data/testA/1" and "/data/test/2", etc.

This is the command I am trying:

azcopy cp "$https://mystorageaccount.blob.core.windows.net/mycontainer?sv=xxxx&ss=xxxx&srt=xxxx&sp=xxxx&se=xxxx&st=xxxx&spr=xxxx&sig=xxxx" /var/data/ --include-regex "*/testA/*"

However, when this command finishes running after a couple of minutes it has not found any files to download. Why isn't this regex matching files like:

/data/testA/2/file.txt /data/testA/2/file1.txt

1

There are 1 best solutions below

0
On BEST ANSWER

Why isn't azcopy cp --include-regex not matching any files?

I agree with Abdul Niyas P M's comment to escape the pattern's forward slashes with a backslash ('\'). This is because forward slashes in regular expressions have a specific meaning and must be escaped to match them literally.

In my environment, I also faced the same situation, After modifying the regular expression pattern ".*\/sampleB\/.*" matches all files that contain the string "/sampleB/" in their path, regardless of their parent directories.

Sample:

PS C:\Users\xxxxx> azcopy cp "https://xxxxxx.blob.core.windows.net/demo?sp=racwdli&st=2023-11-06T05:40:33Z&se=2023-11-06T13:40:33Z&spr=https&sv=2022-11-02&sr=c&sig=xxxxxx" "C:\Users\xxxxx\Venkat" --recursive=true --include-regex ".*\/sampleB\/.*"
INFO: Scanning...
INFO: Any empty folders will not be processed, because source and/or destination doesn't have full folder support
INFO: azcopy.exe: A newer version 10.21.1 is available to download


Job bd5ba996-xxxxxxxx has started
Log file is located at: C:\Users\xxxxxx-f21fe37c9dde.log

100.0 %, 2 Done, 0 Failed, 0 Pending, 0 Skipped, 2 Total, 2-sec Throughput (Mb/s): 0.0006


Job bd5ba996-xxxxxx summary
Elapsed Time (Minutes): 0.0335
Number of File Transfers: 2
Number of Folder Property Transfers: 0
Total Number of Transfers: 2
Number of Transfers Completed: 2
Number of Transfers Failed: 0
Number of Transfers Skipped: 0
TotalBytesTransferred: 161
Final Job Status: Completed

Response:

enter image description here

Reference:

azcopy copy | Microsoft Learn