svnリポジトリのダンプを生成するためのbashスクリプトを作成しました。各ストレージスクリプトをダンプした後、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
。