mysql 5.7全备脚本

#!/bin/bash

mysql_user="root"
mysql_password="mysqlpassword"
mysql_host="192.168.12.30"
mysql_port="3306"
backup_dir=/mysql/fullbackup
base_dir=/usr/local/mysql
backup_date=`date +%Y%m%d_%H%M`

$base_dir/bin/mysqldump -u$mysql_user -p$mysql_password -P$mysql_port -h$mysql_host -A -R -E --triggers --single-transaction --master-data=2 > $backup_dir/mysql_backup_$backup_date.sql

gzip  $backup_dir/mysql_backup_$backup_date.sql

find  $backup_dir -mtime +7 -type f -name "mysql_backup_*" -exec rm -rf {} \;

  

posted @ 2020-09-07 17:11  orcl  阅读(122)  评论(0编辑  收藏  举报