[root@ytest ~]# crontab -l
#0 2 * * * /root/script/mysql1.sh
#30 13 * * * /root/script/mysql2.sh
[root@ytest ~]# cat /root/script/mysql1.sh
#!/bin/sh
cd /root/bak/db
/usr/local/mysql/bin/mysqldump member > /root/bak/db/member.`date +%Y-%m-%d`-1.sql
/usr/local/mysql/bin/mysqldump yoohouse_alpha > /root/bak/db/yoohouse_alpha.`date +%Y-%m-%d`-1.sql
/usr/local/mysql/bin/mysqldump yoohouse_estate > /root/bak/db/yoohouse_estate.`date +%Y-%m-%d`-1.sql
[root@ytest ~]# cat /root/script/mysql2.sh
#!/bin/sh
cd /root/bak/db
/usr/local/mysql/bin/mysqldump member > /root/bak/db/member.`date +%Y-%m-%d`-2.sql
/usr/local/mysql/bin/mysqldump yoohouse_alpha > /root/bak/db/yoohouse_alpha.`date +%Y-%m-%d`-2.sql
/usr/local/mysql/bin/mysqldump yoohouse_estate > /root/bak/db/yoohouse_estate.`date +%Y-%m-%d`-2.sql
并删除以往相关备份
[root@ytest db]# pwd
/root/bak/db
[root@ytest db]# for i in 01 02 03 04 05 06 07 08 09 ;do rm -rf yoohouse_estate.2010-10-$i-*.sql ;done
[root@ytest db]# for i in 01 02 03 04 05 06 07 08 09 ;do rm -rf yoohouse_alpha.2010-10-$i-*.sql ;done
[root@ytest db]# for i in 01 02 03 04 05 06 07 08 09 ;do rm -rf member.2010-10-$i-*.sql ;done
[root@ytest data]# rm -rf /data/root_bak_09292010/ #删除以前备份 挪过这 故删除
阅读(423) | 评论(0) | 转发(0) |