· KLDP.org · KLDP.net · KLDP Wiki · KLDP BBS ·
dasomoli/Subversion Backup

백업 스크립트


#!/bin/bash

REPOSITORY_PATH="/home/repository"
BACKUP_PATH="/home/svnadmin/repo_backup"
DATECOMMAND="/bin/date"
DATE=$( $DATECOMMAND +%Y%m%d )
PWD="/bin/pwd"
CURRENT_PATH=$( $PWD )

FTP_PROGRAM="/usr/bin/ftp"
OTHER_SERVER="서버 주소"
OTHER_SERVER_ID="계정ID"
OTHER_SERVER_PW="ID 의 패스워드"

echo $DATE
if [ ! -d $REPOSITORY_PATH ]
then
        echo "Repository path is wrong. Please check a this script."
        exit 1
fi

if [ ! -e $BACKUP_PATH ]
then
        mkdir $BACKUP_PATH
fi

if [ ! -d $BACKUP_PATH ]
then
        echo "Backup path is wrong. Please check a this script."
        exit 1
fi

if [ ! -w $BACKUP_PATH ]
then
        echo "Permission denied"
        exit 1
fi

if [ -d $BACKUP_PATH/$DATE ]
then
        echo "Remove a $DATE directory"
        rm -rf $BACKUP_PATH/$DATE
fi

if [ -e $BACKUP_PATH/$DATE.tar.gz ]
then
        echo "Remove a $DATE.tar.gz file."
        rm $BACKUP_PATH/$DATE.tar.gz
fi

echo
echo
echo "**  Starting backup...  **"
echo
echo

mkdir $BACKUP_PATH/$DATE

for i in $( ls $REPOSITORY_PATH ); do
        printf "**  %-30s  ******************\n" $i
        svnadmin dump $REPOSITORY_PATH/$i > $BACKUP_PATH/$DATE/$i.dump
done

cd $BACKUP_PATH
echo
echo "**  Compress a backup directory  *************"
echo

tar cvfz $BACKUP_PATH/$DATE.tar.gz $DATE

echo
echo
echo "**  Backup Complete!  **"
echo
echo "**  Transmit to other server. **"
echo

$FTP_PROGRAM -nvp $OTHER_SERVER << EOF
user "$OTHER_SERVER_ID" "$OTHER_SERVER_PW"
hash
prompt
bin
mput $DATE.tar.gz
EOF

echo
echo "**  Transmission Complete! **"
echo

cd $CURRENT_PATH



sponsored by andamiro
sponsored by cdnetworks
sponsored by HP

Valid XHTML 1.0! Valid CSS! powered by MoniWiki
last modified 2006-06-01 11:50:07
Processing time 0.0035 sec