I am using SVN Server and several repositories have been created under “/home/repositories/”
directory. I will use below script to take all SVN repositories backup on local
system under “/SVN_Backup” path.
Please find below the script for SVN repositories backup.
[root@svn02 ~]# cat /scripts/svn_backup
#!/bin/bash
# Record today’s day of week and Hour
# ---------------------------------------
bakdate=$(date +%A_%H)
echo "--------------------------------"
echo "Running SVN backup $bakdate"
echo "--------------------------------\n"
# From where to backup repos?
# ---------------------------------------
svnrepos="/home/repositories/"
echo "\nGoing to backup all SVN repos located at: $svnrepos
\n"
# Where to save the dump?
# -----------------------------------------
bakdest="/SVN_Backup"
# _________NO-COFIG-REQUIRED-BELOW-THIS-LINE___________
# First go to SVN repo folder
cd $svnrepos
# Just make sure we have write access to backup-folder
if [ -d "$bakdest" ] && [ -w "$bakdest" ] ;
then
# Now $repo has folder names =
project names
for repo in *
do
# do svn dump for each
project
echo "Taking
backup/svndump for: $repo"
echo "Executing :
svnadmin dump $repo > $bakdest/$repo-$bakdate.svn.dump \n"
# Now finally execute the
backup
/usr/bin/svnadmin dump $repo
> $bakdest/$repo-$bakdate.svn.dump
# You can go an extra mile by
applying tar-gz compression to svn-dumps
gzip
$bakdest/$repo-$bakdate.svn.dump
done
else
echo "Unable to continue
SVN backup process."
echo "$bakdest is *NOT* a
directory or you do not have write permission."
fi
# End of backup script
echo "\n\n================================="
echo " - Backup Complete, THANK YOU :-]"
We can schedule the backup script once a day in cron job.
[root@svn02 ~]# crontab -e
00 02 * * * /scripts/svn_backup
2. Restore DUMP of subversion (SVN) Repository.
svnadmin create /path/to/repo_name
svnadmin load /path/to/repo_name < path/to/repo_name.dmp
2. Restore DUMP of subversion (SVN) Repository.
svnadmin create /path/to/repo_name
svnadmin load /path/to/repo_name < path/to/repo_name.dmp
No comments:
Post a Comment