Dec
29
Posted on 29-12-2007
Filed Under (Shell scripting) by Arun Bagul

By using this script we can take HOT backup and dump of subversion repository.

root@indiangnu.org:/home/arun# cat SVN-Backup.sh

#!/bin/bash

echo -e “Welocme to Subversion Backup utility by Arun Bagul”
echo -e “————————————————————–”

BACKUP_DIR=”/root/SVN_DB_Backup”
choice=$1
repository_path=$2
dest_name=$3
mydate=$(date +%d-%b-%Y)
SVNadmin=$(which svnadmin)
SVNlook=$(which svnlook)
#######################
if [ -d $BACKUP_DIR ]; then
echo “Backup directory $BACKUP_DIR exist”
echo -e “——————————————–”
else
echo “Backup directory $BACKUP_DIR does not exist”
exit
fi
#######################
if [ $# -eq 3 ]; then

case $choice in

dump)

backup_path=”${BACKUP_DIR}/${dest_name}_${mydate}”
#svnadmin path and dump $repository_path $backup_path
echo “Dump of Respository”
#echo “svnadmin dump $repository_path > $backup_path”
$SVNadmin dump $repository_path > $backup_path
;;
hotbkup)

backup_path=”${BACKUP_DIR}/${dest_name}_${mydate}_DIR”
#HotBackup of svn repository
echo “Hot Backup…”
#echo “$SVNadmin hotcopy $repository_path $backup_path”
$SVNadmin hotcopy $repository_path $backup_path
;;
esac
######
elif [ $# -eq 1 ]; then
if [ “$choice” = “lookup” ]; then
#svn look up
$SVNlook youngest $repository_path
fi
else
echo “Usage: SVN-Backup.sh { dump|hotbkup|lookup } repository_path dest file/dir_name”
fi

#####
echo “Done”
exit 0

root@indiangnu.org:/home/arun#

  • How to use this script-

root@indiangnu.org:/home/arun# /sbin/SVN-Backup
Welocme to Subversion Backup utility by Arun Bagul
————————————————————–
Backup directory /root/SVN_DB_Backup exist
——————————————–
Usage: SVN-Backup.sh { dump|hotbkup|lookup } repository_path dest file/dir_name
Done
root@indiangnu.org:/home/arun#

eg (1)-

root@indiangnu.org:~# SVN-Backup dump /usr/local/repos/ myrepos
Welocme to Subversion Backup utility by Arun Bagul
————————————————————————————–
Backup directory /root/SVN_Backup exist
——————————————–
Dump of Respository
* Dumped revision 0.
* Dumped revision 1.
* Dumped revision 2.
* Dumped revision 3.
* Dumped revision 4.
Done

root@indiangnu.org:~#

eg (2)-
root@indiangnu.org:~#SVN-Backup hotbkup /usr/local/repos/ myrepos
Welocme to Subversion Backup utility by Arun Bagul
————————————————————————————–
Backup directory /root/SVN_Backup exist
——————————————–
Hot Backup…
Done
root@indiangnu.org:~#SVN-Backup dump /usr/local/repos/ myrepos

Welocme to Subversion Backup utility by Arun Bagul
————————————————————————————–
Backup directory /root/SVN_Backup exist
——————————————–
Dump of Respository
* Dumped revision 0.
* Dumped revision 1.
* Dumped revision 2.
* Dumped revision 3.
* Dumped revision 4.
Done

root@indiangnu.org:~#SVN-Backup hotbkup /usr/local/repos/ myrepos
Welocme to Subversion Backup utility by Arun Bagul
—————————————————————————————–

Backup directory /root/SVN_Backup exist
——————————————–
Hot Backup…
Done
root@indiangnu.org:~#

Similar Posts:

Be Sociable, Share!
(0) Comments    Read More   
Post a Comment
Name:
Email:
Website:
Comments:


www.flickr.com
arunbagul's photos More of arunbagul's photos
Get Adobe Flash player
-->