Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

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
share|improve this question
    
./backup.sh: line 55: syntax error near unexpected token fi' ./backup.sh: line 55: fi' –  K.K Patel Apr 17 '13 at 6:33
    
I am also getting error after adding fi –  K.K Patel Apr 17 '13 at 6:43
    
./backup: line 55: syntax error near unexpected token fi' ./backup: line 55: fi ' –  K.K Patel Apr 17 '13 at 6:47
    
let us continue this discussion in chat –  K.K Patel Apr 17 '13 at 6:51
add comment

1 Answer

up vote 2 down vote accepted

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.

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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