mysql通过mysqldump实现备份,脚本编写

crontab -e

0 3 * * * sh /home/shell/mysql_bakup.sh >> /dev/null 2>&1

#!/bin/bash
/usr/local/mysql/bin/mysqldump -uroot -pmingquan0211 --all-databases --routines --events --triggers | gzip > /home/shell/mysql_bakup/mysql_bakup_`date '+%Y-%m-%d'`.sql.gz

find /home/shell/mysql_bakup -mtime +30 -name "*.gz" -exec rm -rf {} \;

猜你喜欢

转载自www.cnblogs.com/fengzhongzhuzu/p/8962103.html