svn备份bash脚本错误

svn备份bash脚本错误

我已经创建了 bash 脚本来创建 svn 存储库的转储。我想添加这样的功能,在转储每个存储库脚本后,使用 rsync 将其发送到远程服务器并从转储位置删除,然后开始转储下一个存储库。我正在使用以下脚本。

脚本有一些错误帮助我改进它。

#!/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

答案1

结束你的 if 块fi

结束你的循环done

每一个if都要一一对应fi,每一个do都要一一对应done

相关内容