MySQL备份脚本shell
原创
©著作权归作者所有:来自51CTO博客作者dcj3sjt126com的原创作品,请联系作者获取转载授权,否则将追究法律责任
#!/bin/bash
date=`date +%Y%m%d`
backDb=$date.sql
backFile=$date.tar.gz
backHost=135.26.25.36 #FTP服务器IP地址
backUser=ftp #FTP服务器用户名
backPwd= password #FTP密码
/usr/local/mysql/bin/mysqldump dbname -udbuser -pdbpassword > /home/backup/$backDb
echo -e "DB Backup Done!\n"
tar -zcvf /home/phpeye/$backFile /websites/phpeye/
echo -e "File Backup Done!\n"
ftp -n $backHost<<!
user $backUser $backPwd
passive
put /home/backup/$backDb phpeyebackup/$backDb
bye
!
ftp -n<<!
open $backHost 21
user $backUser $backPwd
port
prompt
put /home/phpeye/$backFile phpeyebackup
bye
!
rm -f /home/web_happy/phpeye/$backDb
echo -e "Backup Done!\n"