#!/bin/sh
BackUpDir_Top="/mnt/backup"
BackUpDir="$BackUpDir_Top/`date +%Y-%m-%d`/"
YesterDay=`date -d '-1 day' +%Y-%m-%d`
BackUpServer="140.111.77.113"
Prefix="bludebser-"
BackToDir="/home/backup/"
BackToName="`date +%Y-%m-%d`.tar"
LoginUser="backup"
LoginPasswd="backup"
LoginPort="2121"
if [ `date +%w` == 1 ]
then
FullBackUpDay=1
else
FullBackUpDay=0
fi
if [ ! -d $BackUpDir_Top ]
then
mkdir $BackUpDir_Top
fi
mkdir $BackUpDir
cd $BackUpDir
if [ -d /mnt/backup/"$YesterDay" ] || [ $FullBackUpDay == 1 ]
then
tar --after-date $YesterDay -czvf www-diff.tar.gz /var/www
tar --after-date $YesterDay -czvf etc-diff.tar.gz /etc
tar -czvf mysql-diff.tar.gz /var/lib/mysql
#tar --after-date $YesterDay -czvf mysql-diff.tar.gz /var/lib/mysql
#tar --after-date $YesterDay -czvf home-diff.tar.gz /home
else
tar -czvf www.tar.gz /var/www
tar -czvf etc.tar.gz /etc
tar -czvf mysql.tar.gz /var/lib/mysql
#tar -czvf home.tar.gz /home
fi
#backup to server
#cd $BackUpDir_Top
#tar cvf $Prefix$BackToName $BackUpDir
#ncftpput -u $LoginUser -p $LoginPasswd -P $LoginPort $BackUpServer . $Prefix$BackToName
#rm -rf $Prefix$BackToName
#if [ $FullBackUpDay == 1 ]
#then
# find /mnt/backup -atime +7 -exec rm -rf {} \;
#fi
Dec 1, 2007
[備份] Backup.sh
很久以前寫的簡單備份 script
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment