2011年10月28日金曜日

Subversionサーバー シェルスクリプトでデータをバックアップ

  • このエントリーをはてなブックマークに追加


フルバックアップ

#!/bin/bash

FULL_BK_DIR="/usr/local/svnbk/full"
LOGFILE="/var/log/svn-fullbk.`date "+%Y"`"
REPOS_PATH="/var/svn"
DATETIME=`date "+%Y/%m/%d %T"`

if [ ! -d $FULL_BK_DIR ]
then
        mkdir -p $FULL_BK_DIR
fi

echo $DATETIME "****** The full backup of repository is starting!" >> $LOGFILE
FILE=`which svn-backup-dumps`
if [ "$FILE" == "" ]
then
        echo $DATETIME "The svn-backup-dumps script is required!Please install subversion-tools package!" >> $LOGFILE
        echo >> $LOGFILE
        exit 1
fi

svn-backup-dumps -z $REPOS_PATH $FULL_BK_DIR >> $LOGFILE 2>&1
if [ $? -ne 0 ]
then
        echo $DATETIME "◆Error:Failed in full backup!!" >> $LOGFILE
        echo >> $LOGFILE
        exit 1
fi

echo $DATETIME "****** The backup is done" >> $LOGFILE
echo >> $LOGFILE
exit 0

 

差分バックアップ

#!/bin/bash

INCRE_BK_DIR="/usr/local/svnbk/incremental"
LOGFILE="/var/log/svn-incremental.`date "+%Y%m"`"
REPOS_PATH="/var/svn"
DATETIME=`date "+%Y/%m/%d %T"`
CNT_REVISIONS=100

if [ ! -d $INCRE_BK_DIR ]
then
        mkdir -p $INCRE_BK_DIR
fi

echo $DATETIME "****** The incremental backup of repository is starting!" >> $LOGFILE
FILE=`which svn-backup-dumps`
if [ "$FILE" == "" ]
then
        echo $DATETIME "The svn-backup-dumps script is required!Please install subversion-tools package!" >> $LOGFILE
        echo >> $LOGFILE
        exit 1
fi

svn-backup-dumps -c $CNT_REVISIONS -z $REPOS_PATH $INCRE_BK_DIR >> $LOGFILE 2>&1
if [ $? -ne 0 ]
then
        echo $DATETIME "◆Error:Failed in incremental backup!!" >> $LOGFILE
        echo >> $LOGFILE
        exit 1
fi

echo $DATETIME "****** The backup is done!" >> $LOGFILE
exit 0

この記事がお役にたちましたらシェアをお願いします:)

  • このエントリーをはてなブックマークに追加

0 件のコメント:

コメントを投稿