Subversion backup of multiple repositories via DOS .bat file

I recently had to implement Subversion at work to manage our source code. Part of that implementation was coming up with a way to automate the backup process. Since developers could be accessing code repositories at any time there is a special command (called hotcopy) in Subversion for copying a repository to another location, which you can then backup to disk, tape, etc.

I started out just doing a simple DOS .bat file to run the hotcopy. My plan was to schedule this to run in the Windows scheduler prior to the nightly backup. As I started working on the script though I found myself trying to improve it to be as generic and hands off as possible. I also wanted to backup multiple repositories.

Here are some “features” of the script:

  • It will hotcopy multiple repositories in a specified directory.
  • It can be run attended or unattended
  • It has some basic log functionality

Here is a look at the actual hotcopy command in the .bat file:
ECHO Starting SVN backup for %%G... >> %repolog% & ^
svnadmin hotcopy %repodir%%%G %repodirhot%%%G --clean-logs >> %repolog% & ^

Download it here and rename it from svn_backup.txt to svn_backup.bat.