mysql自动备份脚本

 #!/bin/sh

filename=`date +%Y%m%d`
 
echo starting mysqldump...
/usr/bin/mysqldump -a mas -uroot | gzip > /root/mysql_cron_backup/mas_$filename.gz
echo mysqldump complete, target filename=mas_$filename.gz
 
echo starting upload dump file.
 
# after dump, upload to remote ftp
#------------------------------------------
ftp -i -in <<!
open 1.1.1.1
user sta828 123456
bin
prompt
 
lcd /root/mysql_cron_backup
 
mput mas_$filename.gz
bye
!
#----------------------------------------
 
echo upload done.
 
echo remote dump file.
# remote local file
rm mas_$filename.gz
 
echo done!
 

你可能感兴趣的:(mysql,数据库,crontab,ftp,MysqlDump)