I am trying to backup critical folders and their contents on a daily basis so that, should my data drive fail, I have a backup of the important project files but my working data drive is much larger than my backup drive (19:6) so I would like to restrict the backup to just the important files:
RoboCopy %Source% %Dest% *.* /s /xo /purge
works; the /xo
is to speed up the backup by skipping over files not modified (necessary as it would take more than a day to backup 4+ TB of data) and /purge
ensures the backup drive doesn't have copies of files I no longer need.
The problem is that there are files in folders named QA
that I never want to keep backups of, so specifying /xd QA
should skip over these files... but the naming isn't consistent, sometimes it's QA, other times QA_v2 (or 3 or 4) other examples include dates like QA_20160708. I have searched posts like this one that seem to say it's possible to use a wildcard but all combinations of:
RoboCopy %Source% %Dest% *.* /s /xo /purge /xd "*QA*"
RoboCopy %Source% %Dest% *.* /s /xo /purge /xd *QA*
RoboCopy %Source% %Dest% *.* /s /xo /purge /xf "*QA*"
RoboCopy %Source% %Dest% *.* /s /xo /purge /xf *QA*
RoboCopy %Source% %Dest% *.* /s /xo /purge /xd QA
RoboCopy %Source% %Dest% *.* /s /xo /purge /xf QA
still copy a folder called QA_v2 in %Source%
.
Is there a reliable way to skip folders and subfolders of folders that contain a string with wildcards? It might be important (or not) that I am using a batch file as a scheduled task.
I could do this with a python script using os.walk
but shutil.copyfile
is really slow compared to RoboCopy
so this would be an absolute last resort.
--exclude=*QA*