#!/bin/bash
#FTP信息
FTP_IP=
FTP_USER=
FTP_PASS=
#备份数据库
/etc/init.d/mysqld stop
MySQLBakName=MySQL_$(date +”%Y%m%d”).tar.gz
tar zcf /home/backup/$MySQLBakName /var/lib/mysql
/etc/init.d/mysqld start
#备份网站
WebBakName=Web_$(date +%Y%m%d).tar
tar cf /home/backup/$WebBakName /home/www
#操作FTP
OldMySQL=MySQL_$(date -d -1day +”%Y%m%d”).tar.gz
OldWeb=Web_$(date -d -1day +”%Y%m%d”).tar
cd /home/backup/
/usr/bin/ftp -v -n $FTP_IP << EOF
user $FTP_USER $FTP_PASS
type binary
put $MySQLBakName
put $WebBakName
delete $OldMySQL
delete $OldWeb
bye
EOF
rm -rf /home/backup/*.tar*
|