#!/bin/bash #By martin.liu Today=`date +%Y%m%d` BackupPath=/usr/local/mysql_backup BackupLog=bak_$Today.log BackupFile=$Today.tar.gz DBUser=root DBPassword=‘123456‘ DBHost=localhost mkdir -p $BackupPath/$Today innobackupex --user=$DBUser --password=$DBPassword --slave-info --stream=tar $BackupPath/$Today/ 2> $BackupPath/$Today/$BackupLog | gzip 1> $BackupPath/$Today/$BackupFile
脚本如上,作用是将MySQL内的数据进行全量备份。
结合计划任务
#crontab -e
加入
45 2 * * * /opt/script/mysql_backup.sh
每天凌晨两点四十五分执行一次脚本,完成全量热备
时间: 2024-10-13 06:00:28