unix下自动备份程序
时间:2006-07-18 来源:jiangdaoyou
Unix下自动备份程序 注:我们公司里一些服务器就是通过如下程序,自动备份到ftp服务器上。 08 01 * * 0,3,5 /home/jiang/backup/autobackup.sh autobackup.sh程序如下: #!/bin/bash ############### System Backup to FTP ################
#Power By Jiang Daoyou
#E-mail:[email protected] #1. mkdir /home/jiang/backup
#2. chmod 700 autobackup.sh
#3. crontab -e #System Setup
host="x.x.x.x" #ftp host
UserName=backupuser #ftp user name
Passwd=password #fto user password backup_path="/home/jiang/backup" #set saved backup path
time=`/bin/date |awk '{print $6""$2""$3"_"$4}'|awk -F"_" '{print $2}'|awk -F: '{print $1""$2""$3}'`
file=webserver-$(date +%Y%m%d)$time.tar.gz
#################### backup ######################## #stop mysql database server
#/usr/bin/killall mysqld
#/etc/rc.c/init.d/mysqld stop 对于备份mysql要做适当修改 #sleep 5s #stop 5 second #file tar
#tar -czf $backup_path/$file $backupfile
tar -czf $backup_path/$file /etc /var/log/daemon /var/log/server.log /var/log/httpd /var/log/cmdlog sleep 5s #start mysql database server
#/usr/local/mysql/bin/mysqld_safe --user=mysql & #set your mysqld path
#/etc/rc.d/init.d/mysqld start cd $backup_path
sleep 2s
#file ftp
ftp -i -n <<!
open $host
user $UserName $Passwd
cd pptpserver
bin
mput $file
bye
!
#sleep 10s
rm -rf $backup_path/$file
相关阅读 更多 +