MySQL数据备份脚本

#!/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 -u用户名 -p密码 fight_cancer > fight_cancer.$dates.sql

mysqldump -u用户名 -p密码 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


你可能感兴趣的:(mysql,备份)