shell脚本实现mysql数据库的备份。
shell脚本内容:
复制代码代码示例:
#!/bin/bash
# 备份mysql数据库 # by www.it.net.cn # 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" (责任编辑:IT) |