Centos 7系统Xtrabackup 8.0.x 备份mysql 8.0.x数据
Xtrabackup 安装网上挺多教程,这里就不详细描述
step 1、crontab任务调度
vi /etc/crontab
a、* * * * * root /data_backup.sh >>/tmp/log.log
step 2
重启:systemctl restart crond 重启无效情况,停止服务:systemctl stop crond ,再次启动:systemctl start crond,任务调度就可以跑起来
sh脚本,任务调度执行
#!/bin/bash time1=$(date "+%Y%m%d%H%M%S") folder_name=/backupone$time1; if [! -d "$folder_name" ];then #创建文件夹 mkdir $folder_name fi #执行文件权限 chown mysql.mysql $folder_name #开始备份 echo "begin backup" xtrabackup -uaccount -paccount1123 --backup --target-dir=$folder_name/ echo "over backup ,folder_name:$folder_name"