One of the daily scripts I am running from my bash shell (as a cron job) is to back up my subversion repository in its entirety.
I have a huge drive, so there's no worries about space here, and I can move the daily back up off of my server when the weekly tape backup has a copy of the compressed files.
But, I thought I'd share with you all the script I'm using, as getting it just right, with the options to tar is with the date included is a bit fiddly... Anyway, without further delay, the script:
mkdir /var/tmp/daily sudo svnadmin dump /svn > /var/tmp/daily/daily.svn tar cjPf ~/daily_$(date +%Y%m%d).tar.bz2 /var/tmp/daily rm -rf /var/tmp/daily
Now I can copy the resulting file wherever I want, its in my home directory as
"daily_20120501.tar.bz2"
Note the use of the c j P f in the tar, that's capitol P there... And the use of Y for year, month and day in the date formatter.
And that "/svn" is the source of my Subversion repository
And that "/svn" is the source of my Subversion repository
To restore the file into a clean repository just install your server again, extract the daily you want, so you have a "daily.svn" and run the command:
sudo subversion load /svn < /daily.svn
Again, where /svn is the repository path and /daily.svn can be the full path as you extracted the file.
Hope this is useful.