#!/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
每天凌晨两点四十五分执行一次脚本,完成全量热备
本文出自 “Martin” 博客,请务必保留此出处http://529876181.blog.51cto.com/9524887/1786771
原文地址:http://529876181.blog.51cto.com/9524887/1786771