欢迎各位兄弟 发布技术文章
这里的技术是共享的
一)写在 crontab -e 里面的内容
0 2 * * * /bin/bash /root/backupsql.sh
1)backupsql.sh 的文件内容在下面
#!/bin/sh
backup_mysql="/home/backup/mysql/aaaaa/"
backup_mysqlname="aaaaa`date '+%Y%m%d'`.sql";
/www/wdlinux/mysql-5.1.61/bin/mysqldump -u root -p*\(_\)7de8adbc aaaaa > $backup_mysql$backup_mysqlname
backup_mysql="/home/backup/mysql/bbbbb/"
backup_mysqlname="bbbbb`date '+%Y%m%d'`.sql";
/www/wdlinux/mysql-5.1.61/bin/mysqldump -u root -p*\(_\)7de8adbc bbbbb > $backup_mysql$backup_mysqlname
backup_mysql="/home/backup/mysql/ccccc/"
backup_mysqlname="ccccc`date '+%Y%m%d'`.sql";
/www/wdlinux/mysql-5.1.61/bin/mysqldump -u root -p*\(_\)7de8adbc ccccc > $backup_mysql$backup_mysqlname
2)backupsql.sh 的文件权限为 最好设为 chmod 744 backupsql.sh
二)删除备份 删除60前的备份
0 3 * * * find /home/backup/mysql/aaaaa -mtime +60 -name "*.sql" -exec rm -rf {} \;
10 3 * * * find /home/backup/mysql/bbbbb -mtime +60 -name "*.sql" -exec rm -rf {} \;
20 3 * * * find /home/backup/mysql/ccccc -mtime +60 -name "*.sql" -exec rm -rf {} \;