#--------------------------Mysqldump异地备份-----------------# #!/bin/bash #start mysqldump back /usr/bin/mysqldump -uroot -pP@ssw0rd discuz > $(date +%Y%m%d)-discuz.sql #start tar tar -zcvf $(date +%Y%m%d)mysql.tar.gz ./$(date +%Y%m%d)* #start ftp ftp -n<<! open 42.51.152.166 user yanghongfei yanghongfei binary hash lcd /mysqlbak prompt mput *.tar.gz close bye ! #Del the old file rm -rf $(date +%Y%m%d)-discuz.sql $(date +%Y%m%d)mysql.tar.gz rm -rf $(date +%Y%m%d)*
#用root登陆系统编辑crontab文件末尾添加如下一行,即每天的23:20执行以上脚本
#crontab –e
#20 23 * * 0-6 root cd /mysqlbak;./mysqlbak.sh