Azure azcopy sync --include-regex not working as expected

Gary Spencer 20 Reputation points
2023-12-19T16:38:48.89+00:00

I have constructed an azcopy sync command using regex, but it does not include the files I am expecting it to.

Command:-

azcopy sync --include-regex "\/.*\/ABCD\/.*.xml" $AZSAKEY1 $AZSAKEY2 --recursive=true --s2s-preserve-access-tier=false --include-pattern="*.xml"

I am expecting the regex to include files under a set of date folders with, for example, subdirectories 'ABCD' and xml files under there, like so:-

/2023-12-18/ABCD/abcdef1ab23.xml

I am expecting my regex to include these files, but it does not process these files, however if I repeat the command without the regex specified it includes those files.

I have checked my regex OK using the checker at https://regex101.com/

why isn't the azcopy regex specification including my files / what do I need to do to ensure it includes them?

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

Answer accepted by question author
  1. KapilAnanth 49,856 Reputation points Moderator
    2023-12-20T07:13:28.33+00:00

    @Gary Spencer

    Welcome to the Microsoft Q&A Platform. Thank you for reaching out & I hope you are doing well.

    I understand that you would like to use "--include-regex" parameter with Az Copy to only sync files whose path name matches a pattern.

    I did a Lab set up of your scenario and after playing around with the regular expressions for a while, I arrived at the below solution.

    • Your file name/path is 2023-12-18/ABCD/abcdef1ab23.xml
    • **Not /**2023-12-18/ABCD/abcdef1ab23.xml (i.e., no / at the start)

    So, the pattern becomes

    ".*\/ABCD\/.*.xml"
    

    i.e. no need to match the leading "/"

    Kindly let us know if this helps or you need further assistance on this issue.

    Thanks,

    Kapil


    Please don’t forget to close the thread by clicking "Accept the answer" wherever the information provided helps you, as this can be beneficial to other community members.

    1 person found this answer helpful.

0 additional answers

Sort by: Most helpful

Your answer

Answers can be marked as 'Accepted' by the question author and 'Recommended' by moderators, which helps users know the answer solved the author's problem.