首页mysql › 基于innobackupex的mysql备份脚本

基于innobackupex的mysql备份脚本

基于innobackupex的mysql备份脚本

mysql_backup.sh程序安装说明

1、安装mysqlbackup程序
上传mysqlbackup到服务器/tmp目录
cd /tmp
unzip mysqlbackup.zip
cp /tmp/mysqlbackup/* /opt/mysql/product/5.1/bin
mkdir -p /opt/MySqlBackUp/bin
mkdir -p /opt/MySqlBackUp/data
mkdir -p /opt/MySqlBackUp/logs
mkdir -p /opt/MySqlBackUp/temp
ln -s /opt/mysql/product/5.1/bin/innobackupex /opt/MySqlBackUp/bin/innobackupex

对innobackupex进行授权
cd /opt/mysql/product/5.1/bin/
chmod +x innobackupex*
chmod +x xtrabackup*
chmod +x tar4ibd

cp /tmp/mysqlbackup/mysql_backup.sh /opt/MySqlBackUp/bin/
chmod 775 /opt/MySqlBackUp/bin/mysql_backup.sh

2、修改mysql_backup.sh中的相关数据
dbuser
dbpasswd
mail
dumpdb

3、配置mysql环境变量到root中
export MYSQL_BASE=/opt/mysql
export BASEDIR=$MYSQL_BASE/product/5.1
export DATADIR=$MYSQL_BASE/mysqldata
export LD_LIBRARY_PATH=$BASEDIR/lib:/lib:/usr/lib:/usr/local/lib
export TMPDIR=/tmp
export PATH=${PATH}:/usr/bin:/bin:/usr/bin/X11:/usr/local/bin
export PATH=${PATH}:$BASEDIR/bin:$MYSQL_BASE:$BASEDIR:$LD_LIBRARY_PATH

添加到/root/.bash_profile文件中

4、测试备份
cd /opt/MySqlBackUp/bin
./mysql_backup.sh

5、查看备份是否成功
cat /opt/MySqlBackUp/logs/result.log
如果提示备份成功,则表示程序安装成功,可能不熟到crontab中

6、部署crontab
0 1 * * * (cd /opt/MySqlBackUp/bin;sh ./mysql_backup.sh)

说明:参数配置,均是基于按照mysql安装路径配置

 

 

发表评论