0

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="root@192.168.11.156:/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
4
  • ./backup.sh: line 55: syntax error near unexpected token fi' ./backup.sh: line 55: fi' – KK Patel Apr 17 '13 at 6:33
  • I am also getting error after adding fi – KK Patel Apr 17 '13 at 6:43
  • ./backup: line 55: syntax error near unexpected token fi' ./backup: line 55: fi ' – KK Patel Apr 17 '13 at 6:47
  • let us continue this discussion in chat – KK Patel Apr 17 '13 at 6:51
2

End your if blocks with fi

End your loops with done

Each if must be matched by one fi, and each do must be matched by one done.

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.