Backup all SVN repostiroes using a one-liner Shell script
Posted: March 9th, 2011 | Author: shesek | Filed under: SVN | Tags: backup, shell script, svn backup, svn repositories | No Comments »Just a quick one-liner to backup all your SVN repositories. It lists the directories under the main SVN directory, uses xargs to run the dump for every repository, gzip’s the dump and saves each dump to a file named according to the repository name and the current date.
In this example, the main SVN directory is /var/svn/ and the backup location is /backup/svn/. Change those to the paths used by you.
ls /var/svn/ | xargs -I {} sh -c "svnadmin dump /var/svn/{} | gzip -c > /backup/svn/{}.`date +'%F'`.dump.gz"
You can also SCP the backup to a remote server using this:
ls /var/svn/ | xargs -I {} sh -c "svnadmin dump /var/svn/{} | gzip -c > /backup/svn/{}.`date +'%F'`.dump.gz; scp -p /backup/svn/{}.`date +'%F'`.dump.gz username@hostname:/backup/svn/"