#!/bin/bash
#MySQL备份
dates=`date +%Y%m%d`
datey=`date -d"30 days ago" +%Y%m%d`
mkdir -p /home/backup
cd /home/backup
mysqldump -uroot -pwyqj_root fight_cancer > fight_cancer.$dates.sql
mysqldump -uroot -pwyqj_root redmine > redmine.$dates.sql
mkdir -p /home/backup/fight_cancer
mkdir -p /home/backup/redmine
gzip fight_cancer.$dates.sql
gzip redmine.$dates.sql
mv fight_cancer.$dates.sql.gz /home/backup/fight_cancer
mv redmine.$dates.sql.gz /home/backup/redmine
rm -rf /home/backup/fight_cancer/fight_cancer.$datey.sql.gz
rm -rf /home/backup/redmine/redmine.$datey.sql.gz
原文:http://yyyummy.blog.51cto.com/8842100/1410554