I'm trying to get the script here working on my Ubuntu Server to backup the SVN repository via a cron.
#!/bin/bash
BACKUP_DIR="/backup/repository"
REPOSITORY_DIR="/home/svn/repository"
#search in repository folder to find all the repository names
ls -Al --time-style=long-iso /home/svn/repository/ | grep '^d' | awk '{print $8}' | while read line
do
if [ ! -d $BACKUP_DIR"/"$line ]; then
mkdir $BACKUP_DIR"/"$line
fi
#Getting revision number
REVISION=`cat $REPOSITORY_DIR"/"$line"/db/current" | awk '{print $1}'`
#Archive last backup
tar -czf $BACKUP_DIR"/"$line"-last.tar.gz" $BACKUP_DIR"/"$line"/"
#Dangerous :)
if [ -n "$BACKUP_DIR" ]; then
rm -rf $BACKUP_DIR"/"$line"/*"
fi
#Check to see if exists a hot backup
if [ -d $BACKUP_DIR"/"$line"/"$line"-"$REVISION ]; then
echo "Skipping Backup ! Backup Already Exists"
else
echo "Doing backup for "$line
/usr/bin/svn-hot-backup $REPOSITORY_DIR"/"$line $BACKUP_DIR"/"$line
fi
done
I've changed the paths to the correct ones, and subversion-tools is installed, however I get the following errors if I try and run sudo bash svnbackup.sh:
: command not foundline 2:
svnfullbackup.sh: line31: syntax error near unexpected token 'done'
svnfullbackup.sh: line31: 'done'
I presume these errors are why the cron didn't work at its alloted time. How can I fix them?