欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页  >  数据库

基于Innobackupex的MySQL备份脚本

程序员文章站 2024-01-22 21:10:10
...

Innobackupex是Xtrabackup的一部分,其实质也是调用xtrabackup。主要的不同是Xtrabackup除了支持innodb引擎外还支持xtradb引擎。

Innobackupex是Xtrabackup的一部分,其实质也是调用xtrabackup。主要的不同是Xtrabackup除了支持innodb引擎外还支持xtradb引擎。本文主要封装了Innobackupex到shell脚本进行定期备份,供大家参考。

1、脚本描述
a、支持增量备份以及全备
b、需要传递到备份脚本(如备份路径,连接相关参数等)
c、基于周日,周三的全量备份,其他增量备份
d、可根据需要调整脚本,,比如压缩备份的文件夹以及rsync等

2、脚本内容

################################################################################
# File : innobk.sh #
# Author : Leshami #
# Blog : #
# Date : 20141113 #
# Description : #
# The script will call innobackupex to #
# take a full or increment backup for mysql db. #
# Currently it will take follow principal to backup: #
# Sun,Wend take full backup. #
# Mon,Tue,Thur,Fri,Sat take incremental backup. #
# #
# Usage Example: #
# innobk.sh --help|-? #
# innobk.sh --backup-dir=/dbbak --defaults-file=/inst3606/my3606.cnf \ #
# --host=127.0.0.1 --port=3606 --user=xxx --password=xxx #
# #
################################################################################
# Change History: #
# -------------------------------------------------- #
# Init Development Leshami 2014-11-13 #
################################################################################

#!/bin/bash
#set -x

# Get the key value of input arguments format like '--args=value'.
function get_key_value()
{
echo "$1" | sed 's/^--[a-zA-Z_-]*=//'
}

# Usage will be helpful when you need to input the valid arguments.
function usage()
{
cat Usage: $0 [configure-options]
-?, --help Show this help message.
--backup-dir= Set backup directory
--defaults-file=[] Set mysql configuration file directory
--host= Set mysql host
--port= Set mysql port
--user= Set mysql user name
--password= Set mysql user password
EOF
}