innobackup增量备份脚本
发表于:2025-01-21 作者:千家信息网编辑
千家信息网最后更新 2025年01月21日,参考涂抹mysql里的脚本,做了下改进[mysql@mysql01 scripts]$ cat mysql_full_backup_by_xtra.sh#!/bin/sh# Created by wk
千家信息网最后更新 2025年01月21日innobackup增量备份脚本参考涂抹mysql里的脚本,做了下改进
[mysql@mysql01 scripts]$ cat mysql_full_backup_by_xtra.sh
#!/bin/sh
# Created by wk
DATA_PATH=/data/mysqldata/backup/mysql_full
DATA_FILE=${DATA_PATH}/xtra_fullbak_`date +%Y%m%d%H%M`
LOG_FILE=${DATA_PATH}/xtra_fullbak_`date +%Y%m%d%H%M`.log
ORI_CONF_FILE=/data/mysqldata/3306/my.cnf
NEW_CONF_FILE=${DATA_PATH}/my_3306_`date +%Y%m%d%H%M`.cnf
MYSQL_PATH=/data/mysqldata/backup/innobackupex/bin
MYSQL_CMD="${MYSQL_PATH}/innobackupex --user=root --password=pass1 --defaults-file=/data/mysqldata/3306/my.cnf --no-lock --no-timestamp ${DATA_FILE}"
echo > $LOG_FILE
echo -e "==== Jobs started at `date +%F' '%T' '%w` ====\n" >> $LOG_FILE
echo -e "==== First cp my.cnf file to backup directory ====" >> $LOG_FILE
/bin/cp ${ORI_CONF_FILE} ${NEW_CONF_FILE}
echo >> $LOG_FILE
#echo -e "**** Executed command:${MYSQL_CMD} | gzip > ${DATA_FILE}" >> $LOG_FILE
${MYSQL_CMD} 2>>${LOG_FILE}
echo -e "**** Executed finished at `date +%F' '%T' '%w` ====" >> $LOG_FILE
echo -e "**** Backup file size: `du -sh ${DATA_FILE}` ====\n" >> ${LOG_FILE}
echo -e "---- Find expired backup and delete those files ----" >> ${LOG_FILE}
for tfile in $(/usr/bin/find $DATA_PATH/ -mtime +6)
do
if [ -d $tfile ] ; then
rmdir $tfile
elif [ -f $tfile ] ; then
rm -f $tfile
fi
echo -e "---- Delete tfile: $tfile ----" >> ${LOG_FILE}
done
echo -e "\n==== Jobs ended at `date +%F' '%T' '%w` ====\n" >> $LOG_FILE
echo "backup_full=${DATA_FILE}" >/data/mysqldata/scripts/backup.conf
echo "backup_pre_name=${DATA_FILE}" >>/data/mysqldata/scripts/backup.conf
[mysql@mysql01 scripts]$ cat mysql_incr_backup_by_xtra.sh
#!/bin/sh
# Created by wk
source /data/mysqldata/scripts/backup.conf
DATA_PATH=/data/mysqldata/backup/mysql_full
DATA_FILE=${DATA_PATH}/xtra_incrbak_`date +%Y%m%d%H%M`
#OLD_DATA_FILE=${DATA_PATH}/xtra_fullbak_`date -d "1 days ago" +"%F"`
LOG_FILE=${DATA_PATH}/xtra_incrbak_`date +%Y%m%d%H%M`.log
ORI_CONF_FILE=/data/mysqldata/3306/my.cnf
NEW_CONF_FILE=${DATA_PATH}/my_3306_`date +%Y%m%d%H%M`.cnf
MYSQL_PATH=/data/mysqldata/backup/innobackupex/bin
MYSQL_CMD="${MYSQL_PATH}/innobackupex --user=root --password=pass1 --defaults-file=/data/mysqldata/3306/my.cnf --incremental --no-lock --no-timestamp
--incremental-basedir=${backup_pre_name} ${DATA_FILE}"
echo > $LOG_FILE
echo -e "==== Jobs started at `date +%F' '%T' '%w` ====\n" >> $LOG_FILE
echo -e "==== First cp my.cnf file to backup directory ====" >> $LOG_FILE
/bin/cp ${ORI_CONF_FILE} ${NEW_CONF_FILE}
echo >> $LOG_FILE
echo -e "**** Executed command:${MYSQL_CMD} | gzip > ${DATA_FILE}" >> $LOG_FILE
${MYSQL_CMD} 2>>${LOG_FILE}
echo -e "**** Executed finished at `date +%F' '%T' '%w` ====" >> $LOG_FILE
echo -e "**** Backup file size: `du -sh ${DATA_FILE}` ====\n" >> ${LOG_FILE}
echo -e "---- Find expired backup and delete those files ----" >> ${LOG_FILE}
for tfile in $(/usr/bin/find $DATA_PATH/ -mtime +6)
do
if [ -d $tfile ] ; then
rmdir $tfile
elif [ -f $tfile ] ; then
rm -f $tfile
fi
echo -e "---- Delete tfile: $tfile ----" >> ${LOG_FILE}
done
echo -e "\n==== Jobs ended at `date +%F' '%T' '%w` ====\n" >> $LOG_FILE
echo "backup_full=${DATA_FILE}" >/data/mysqldata/scripts/backup.conf
echo "backup_pre_name=${DATA_FILE}" >>/data/mysqldata/scripts/backup.conf
[mysql@mysql01 scripts]$ cat backup.conf
backup_full=/data/mysqldata/backup/mysql_full/xtra_incrbak_201609011805
backup_pre_name=/data/mysqldata/backup/mysql_full/xtra_incrbak_201609011805
[mysql@mysql01 scripts]$ cat mysql_full_backup_by_xtra.sh
#!/bin/sh
# Created by wk
DATA_PATH=/data/mysqldata/backup/mysql_full
DATA_FILE=${DATA_PATH}/xtra_fullbak_`date +%Y%m%d%H%M`
LOG_FILE=${DATA_PATH}/xtra_fullbak_`date +%Y%m%d%H%M`.log
ORI_CONF_FILE=/data/mysqldata/3306/my.cnf
NEW_CONF_FILE=${DATA_PATH}/my_3306_`date +%Y%m%d%H%M`.cnf
MYSQL_PATH=/data/mysqldata/backup/innobackupex/bin
MYSQL_CMD="${MYSQL_PATH}/innobackupex --user=root --password=pass1 --defaults-file=/data/mysqldata/3306/my.cnf --no-lock --no-timestamp ${DATA_FILE}"
echo > $LOG_FILE
echo -e "==== Jobs started at `date +%F' '%T' '%w` ====\n" >> $LOG_FILE
echo -e "==== First cp my.cnf file to backup directory ====" >> $LOG_FILE
/bin/cp ${ORI_CONF_FILE} ${NEW_CONF_FILE}
echo >> $LOG_FILE
#echo -e "**** Executed command:${MYSQL_CMD} | gzip > ${DATA_FILE}" >> $LOG_FILE
${MYSQL_CMD} 2>>${LOG_FILE}
echo -e "**** Executed finished at `date +%F' '%T' '%w` ====" >> $LOG_FILE
echo -e "**** Backup file size: `du -sh ${DATA_FILE}` ====\n" >> ${LOG_FILE}
echo -e "---- Find expired backup and delete those files ----" >> ${LOG_FILE}
for tfile in $(/usr/bin/find $DATA_PATH/ -mtime +6)
do
if [ -d $tfile ] ; then
rmdir $tfile
elif [ -f $tfile ] ; then
rm -f $tfile
fi
echo -e "---- Delete tfile: $tfile ----" >> ${LOG_FILE}
done
echo -e "\n==== Jobs ended at `date +%F' '%T' '%w` ====\n" >> $LOG_FILE
echo "backup_full=${DATA_FILE}" >/data/mysqldata/scripts/backup.conf
echo "backup_pre_name=${DATA_FILE}" >>/data/mysqldata/scripts/backup.conf
[mysql@mysql01 scripts]$ cat mysql_incr_backup_by_xtra.sh
#!/bin/sh
# Created by wk
source /data/mysqldata/scripts/backup.conf
DATA_PATH=/data/mysqldata/backup/mysql_full
DATA_FILE=${DATA_PATH}/xtra_incrbak_`date +%Y%m%d%H%M`
#OLD_DATA_FILE=${DATA_PATH}/xtra_fullbak_`date -d "1 days ago" +"%F"`
LOG_FILE=${DATA_PATH}/xtra_incrbak_`date +%Y%m%d%H%M`.log
ORI_CONF_FILE=/data/mysqldata/3306/my.cnf
NEW_CONF_FILE=${DATA_PATH}/my_3306_`date +%Y%m%d%H%M`.cnf
MYSQL_PATH=/data/mysqldata/backup/innobackupex/bin
MYSQL_CMD="${MYSQL_PATH}/innobackupex --user=root --password=pass1 --defaults-file=/data/mysqldata/3306/my.cnf --incremental --no-lock --no-timestamp
--incremental-basedir=${backup_pre_name} ${DATA_FILE}"
echo > $LOG_FILE
echo -e "==== Jobs started at `date +%F' '%T' '%w` ====\n" >> $LOG_FILE
echo -e "==== First cp my.cnf file to backup directory ====" >> $LOG_FILE
/bin/cp ${ORI_CONF_FILE} ${NEW_CONF_FILE}
echo >> $LOG_FILE
echo -e "**** Executed command:${MYSQL_CMD} | gzip > ${DATA_FILE}" >> $LOG_FILE
${MYSQL_CMD} 2>>${LOG_FILE}
echo -e "**** Executed finished at `date +%F' '%T' '%w` ====" >> $LOG_FILE
echo -e "**** Backup file size: `du -sh ${DATA_FILE}` ====\n" >> ${LOG_FILE}
echo -e "---- Find expired backup and delete those files ----" >> ${LOG_FILE}
for tfile in $(/usr/bin/find $DATA_PATH/ -mtime +6)
do
if [ -d $tfile ] ; then
rmdir $tfile
elif [ -f $tfile ] ; then
rm -f $tfile
fi
echo -e "---- Delete tfile: $tfile ----" >> ${LOG_FILE}
done
echo -e "\n==== Jobs ended at `date +%F' '%T' '%w` ====\n" >> $LOG_FILE
echo "backup_full=${DATA_FILE}" >/data/mysqldata/scripts/backup.conf
echo "backup_pre_name=${DATA_FILE}" >>/data/mysqldata/scripts/backup.conf
[mysql@mysql01 scripts]$ cat backup.conf
backup_full=/data/mysqldata/backup/mysql_full/xtra_incrbak_201609011805
backup_pre_name=/data/mysqldata/backup/mysql_full/xtra_incrbak_201609011805
脚本
参考
增量
备份
数据库的安全要保护哪些东西
数据库安全各自的含义是什么
生产安全数据库录入
数据库的安全性及管理
数据库安全策略包含哪些
海淀数据库安全审计系统
建立农村房屋安全信息数据库
易用的数据库客户端支持安全管理
连接数据库失败ssl安全错误
数据库的锁怎样保障安全
一个软件如何从数据库改端口
网络安全法第二十四
牧童把老马的服务器打爆了
软件开发直接计入管理费用
软件开发报表系统
生物催化和生物降解的数据库
山东佳宏网络技术有限公司
网络安全主要措施
factset数据库能干啥
java软件开发综合应用
网络技术运营管理是做什么的
攻击服务器的方式
web访问数据库的技术
上海商业软件开发市场价
软件开发啊 知乎
网络安全文明上网的黑板报
智媒易达软件开发
达拉特旗网络安全监察大队
黄陂区方便网络安全维护报价表
福州培训直播软件开发
贵州拼接服务器厂家
与web服务器安全有关的
列组数据库命名空间
谷歌网络安全最新消息
老头环连接服务器失败
融媒体网络技术题
计算机网络技术与5G
参加网络安全攻防竞赛报道
校园网络安全写的内容
服务器管理器web服务器