SvnBackup - backup your local working copy modifications

by Mark 25. July 2011 21:13

I love a command line utility, and after recently losing a hard disc full of uncommitted SVN changes, the need for a new one arose.

The resulting utility (SvnBackup), takes a list of local working copy directories and queries them using the "svn status" command.  A list of added, modified, or unversioned files is compiled, and the files are then copied to a specidied backup location. 

System requirements are that you have an SVN client installed on your machine (I use TortoiseSvn), and at least version 3.5 of the .NET runtime.

I've setup a scheduled task on my dev box which is triggered every time I lock my machine.  The task executes SvnBackup like this (paths have been changed to protect the innocent):

svnbackup.exe -d "z:\backup" src="d:\src\some-important-website,d:\src\common-utils,d:\src\android" > "C:\logs\backup.txt"

The scheduled task also pipes the console output to a text file, giving me visibility of any problems.

Something I've not done before is use System.Diagnostics.Trace instead of System.Console when writing to the screen.  For console applications this makes the implementation of a "quiet" flag very simple; Messages will only be written to the screen if you explicitly add a ConsoleTraceListener, like this:

if (programSettings.WriteToConsole)
{
    Trace.Listeners.Add(new ConsoleTraceListener());
}


Download here: SvnBackup.zip (7.30 kb)

Tags:

SVN

About the author

I'm a software developer living and working in Cambridge.  In my spare time I tinker with old computers, old bikes and old cars.

Month List