Dump Multiple SVN

How to make a backup of all repositories in a folder

As a Software Developer it is required from time to time to make a backup from the all your own repositories.
A usual and the easiest way ist to login into your shell and make dumps as we described here - How To make a SVN Backup and Restore. With a small quantity of repos. it is okay to use this. But, if you have some hundred of repositories it is a hairy and time eating procedure.
That's why we created a small shell script to make a dump of all repositories in folder.

System Requirements

No special requirements. If you have a running SVN server on a Linux system all required parts are onboard.
The only thing to know is, where is svnadmin located:

root@server:~# whereis svnadmin
svnadmin: /usr/bin/svnadmin
root@server:~#
            

As next we create a empty shell script called: multidump.sh

root@server:~# touch multidump.sh
    

Now we make this file executable.

root@server:~# chmod +x multidump.sh
    

The content of file

#!/bin/bash
REPO_BASE=/location/where/your/svn/root/folder/is/
TARGET=/location/of/storage/
SVNADMIN=/usr/bin/svnadmin

cd "$REPO_BASE"
for f in *; do
	FILE="$TARGET$f.dump"
	echo "Dump: $f => $FILE"
    test -d "$f"  &&  $SVNADMIN dump "$f" > "$FILE"
done
    

Change REPO_BASE into the folder where your SVN repositories are located.
Target is the folder where the should be stored.
SVNADMIN is the path you get by whereis svnadmin

After changing the variable content, the script can be executed.

root@server:~# ./multidump.sh
    

No failure? Fine.
After dumping all dump's can be compressed to safe space. But this step we can also do in our script, change it!

#!/bin/bash
REPO_BASE=/location/where/your/svn/root/folder/is/
TARGET=/location/of/storage/
SVNADMIN=/usr/bin/svnadmin

cd "$REPO_BASE"
for f in *; do
	FILE="$TARGET$f.dump.gz"
	echo "Dump: $f => $FILE"
    test -d "$f"  &&  $SVNADMIN dump "$f" | gzip -9 > "$FILE"
done
    

This script creates now dump's of all our SVN repositories and compress it in the same way.



Status: 2015-12-01