Month: June 2008

A working copy for the weekend

Sometimes it’s good to be able to review some code out of working hours when you suddenly have some inspiration. Using nncron, svn export, 7z and FTP (TLS) I’ve been able to automate this quite easily.

# at 5pm export a working copy, archive it and transfer the archive by FTP over TLS.
0 17 * * 1-5 CMD /K "C:\Documents and Settings\Placeholder\My Documents\scripts\svn_export.bat"

In the batch file:
set project=myProject
REM Export the working copy.
"C:\Program Files\Subversion\bin\svn.exe" export --ignore-externals C:\svn\%project% C:\svn\export\%project%
REM Create an archive of the files.
"C:\Program Files\7-Zip\7z.exe" u "C:\svn\export\%project%.7z" "C:\svn\export\%project%\*"
REM Move the archive to another location.
"C:\Program Files\BlueZone FTP\Bzftpf.exe" /Fdummy.zft /Z0 /L"MPUT *.7z" /L"EXIT"

I used the BlueZone Secure FTP Client as it supports FTP over TLS (I don’t want my login being broadcast) and it was scriptable. I use 7-Zip as the 7z archive is smaller than a ZIP file (over 40% smaller). I had to install Subversion as although TortoiseSVN is scriptable its ‘export’ function wasn’t exactly what I wanted (my current working copy without unversioned files).


Microsoft’s Task Scheduler rarely cuts it in the real world. Cron does but I didn’t want to have to install Cygwin and play around with it. I found nnCron instead (I’m using the LITE version) and was quickly able to set up an hourly job that runs during working hours. The job calls a DOS batch file that makes a couple of calls to SyncToy folder sets which echo my working copies across to a network share just in case, when I’m working on a large piece of code, I’ve not checked in and something goes horribly wrong. Very reassuring.

The line in the
# echo working copies to a network folder every hour between 8am and 6pm every weekday.
0 8-18 * * 1-5 "C:\Documents and Settings\My Account\My Documents\scripts\synctoy_echo.bat"

The lines in the batch file:
REM Use SyncToy at the command line to run folder sets.
REM The SyncToy syntax requires the use of quotes and that tends to confuse DOS so
REM fire each call to SyncToy in its own shell, use /C to terminate the shell after SyncToy has run and
REM use the /S flag to indicate the use of more than two quotation marks on the command line (/S will strip
REM the first and last of them and present the rest to the shell).
cmd /S /C ""C:\Program Files\SyncToy\SyncToy.exe" -R"SVN Echo""
cmd /S /C ""C:\Program Files\SyncToy\SyncToy.exe" -R"ESPC Echo""