Svn – How to use a batch file to dump only the last few weeks’ revisions in SVN

batchdumpsvn

We were previously backing up our full SVN dump each night, but the repository has now become too large.

If I was willing to cut off the revision history at say 2 weeks, how would I go about making a batch script to perform this dump?

I realise svnadmin dump can take a revision range, but I'm not sure how to write a script to get the revision number corresponding to a time in the past, e.g. 14 days ago.

Best Answer

The help text doesn't show it, but you can specify a revision range using dates or a few keywords, the same as you can with the normal svn commands. To dump commits from the previous month up to the current HEAD:

svnadmin dump /path/to/repo/ -r {2011-05-20}:HEAD > /path/to/dumpfile

Bear in mind that this method means you need to ensure that your snapshots catch every revision and don't overlap, since the dump files don't contain explicit revision numbering information. The restoration method of svnadmin load will just replay and renumber your revisions if there's any missing or any overlap.

I should mention svnadmin hotcopy as a backup option, since they're much faster than dumps. (You can take regular, offline dumps from the hotcopy if text dumps are what you need).