2
I am trying to use Robocopy to create client software builds by copying all the necessary files out of our main repository. We have multiple clients each needing their own custom software builds.
I have a list of requirements for each client's build. My thinking is to copy over the core stuff first (binaries and such, used by all clients) and then copy over the client specific stuff depending on for whom I'm making a build by making use of these lists. We have something like this already working with xcopy.
There is obviously a bunch of stuff I want excluded from the client build such as source files, log files and obviously all the client specific stuff. I thought by making clever use of the /xf
and /xd
switches I should be able to get it to work.
After a getting all the needed info, the following command is built in Lua
:
robocopy "Z:\path\to\source" "../dest" /e /xf *.cpp *.h *.hpp [[. . .]] *.cxx /xd Data/Testing Data/Some/Client/Data Data/Other/Client/Data [[ . . .]] Data/More/Directories
When running it I get the following output:
-------------------------------------------------------------------------------
ROBOCOPY :: Robust File Copy for Windows
-------------------------------------------------------------------------------
Started : Tuesday, August 1, 2017 11:15:59 AM
Source : Z:\path\to\source
Dest : ../dest
Files : *.*
Exc Files : *.cpp
*.h
*.hpp
[[. . .]]
*.cxx
Exc Dirs : Data/Testing
Data/Some/Client/Data
Data/Other/Client/Data
[[ . . .]]
Data/More/Directories
Options : *.* /S /E /DCOPY:DA /COPY:DAT /R:1000000 /W:30
------------------------------------------------------------------------------
The output tells me my command is formatted properly and that Robocopy understands what I'm asking it to do.
The problem is that it's straight up ignoring the Exc dirs
list and is just copying everything. I do not want to exclude the whole Data
directory, but only the bits inside it that are relevant.
If I use back slashes (\
) then the Exc dirs
output is printed like Data\\testing
. Could this be my issue?
Did you try to use absolute paths? Did you try to build a small example to see what kind of slashes you need? – Seth – 2017-08-01T11:43:16.133
I am trying to avoid absolute paths because the scripts must be able to run on any machine, with the repository installed anywhere. The script is part of the main repository, so we use relative paths then. I am building a small example now to test the theory of the slashes. – getack – 2017-08-01T11:47:10.010
If you don't want to use full explicit paths of the excluded then just use the sub folder name only of some top level subfolder name, etc. to tell the job to exclude i.e.
/XD "Testing Data" "More"
and that should work but for all subfolders matching that name so you may need to rethink the folder naming for the dirs you want to exclude and append a character to make them unique if the name is not unique otherwise per the job so"/z_Testing Data"
for example. Otherwise, consider putting dirs to not backup in a standard top level parent folder e.g.\NoBackup\Testing Data
. Simple to test. – Pimp Juice IT – 2017-08-01T12:39:09.150Our repository is almost 20 years old. Changing the directory layout to something more sensible is unfortunately not possible due to technical inertia. – getack – 2017-08-01T13:29:04.137
I don't really get why you would not be able to use absolute paths. Your original question states you're generating the robocopy line using LUA and also already include an absolute path. But well, it seems you've found an answer that works for you. Interesting though that your XCOPY approach works as it should have the same behavior. Maybe exclude the full example of what you did in your answer, as it might be helpful. – Seth – 2017-08-02T05:53:38.870