I have created bash script for create dump of svn repositories. I want to add such functionality that after dump of every repository script send it to remote server using rsync and delete from dump location and after that starts to make dump of next repository. I am using following script.
script has some errors help me to improve it.
#!/bin/sh
# Record todays date
# --------------------
bakdate=$(date +%Y%m%d)
echo "--------------------------------"
echo "Running SVN backup $bakdate"
echo "--------------------------------\n"
# From where to backup repos?
# ---------------------------
svnrepos="/kk/svn/"
echo "\nGoing to backup all SVN repos located at: $svnrepos \n"
# Where to save the dump?
# ------------------------
bakdest="/save/"
# Location of remote server (to copy backup)
# ----------------------------------------
baktoremote="[email protected]:/kk"
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.dump \n"
# Now finally execute the backup
svnadmin dump $repo > $bakdest/$repo-$bakdate.dump
# 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
svnadmin dump $repo > $bakdest/$repo-$bakdate.dump
# sent it to remote server
rsync -avP $bakdest/$repo-$bakdate.dump $baktoremote
# delete repository after sending
rm -rf $repo-$bakdate.dump
fi
fi' ./backup.sh: line 55:
fi' – K.K Patel Apr 17 at 6:33fi' ./backup: line 55:
fi ' – K.K Patel Apr 17 at 6:47