I’m looking for the best way to run a nightly script that exports a set of files from a SVN Repository to a local directory. When the export finishes, copy the contents of the local directory to several remote servers.
This will be a scheduled back job running on a Windows Server 2003 machine. Remote servers are all on the network, so there’s no need for FTP, etc.
Pseudocode would run like this
1. svn export repo localdir (plus some switches) 2. ... wait to make sure export is finished ... 3. robocopy localdir \\remotedir1 4. robocopy localdir \\remotedir2, etc
I’m very new to writing batch jobs, but I’d like this to be as robust as possible: – copy doesn’t start until export is done – if copy to remotedir1 fails, script still proceeds copying to remotedir2,3,etc – is it possible to log problems if there is any trouble at one of the steps?
Any input on what the batch job would look like would be much appreciated!
You probably don’t need step 2 to wait since SVN blocks while exporting. Apart from that it looks good. You can use
to log failures and stop the batch if the export fails.
||basically tells that the command(s) after the||only get executed when the preceding command fails (errorlevel > 0).goto :eofexits the batch file (or subroutine), alternatively you could useexit /bfor this.You can apply this chaining to the robocopy commands as well:
or something like this.
Another, more verbose way would be an
ifblock after each command you want to safeguard:All of these methods need proper exit codes from the tools, though.