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.
Just a quick comment for you all, I've run this script for a few days whilst I bring a new server online, yesterday I imported the 1.7gb library of stuff into the repository... This resulted in the server taking a HUGE amount of time to dump and compress the backup that evening...
ReplyDeleteThis is nice however it doesnt backup the whole repo.
ReplyDeleteconfig files, hooks, locks, etc are lost.
Spot on, its just a dump of the contents... Mainly to help migrate to another service or server, but works as a good back up procedure in the midst of adversity too.
Delete