innobackupex全量備份和增量備份指令碼

2021-09-20 19:50:17 字數 2050 閱讀 7989

# 每週六凌晨一次的全備份。

20 4 * * 6 /root/fullbackupdata.sh

資料庫全備份的指令碼

#!/bin/bash

dateformat=$(date +"%y-%m-%d")

direc=/mnt/backup

fulldir=$direc/full

logdir=/home/backuplog

fulllog=$logdir/fulllog

user=root

password=root

doif [ ! -d $i ]; then

mkdir -pv $i

fidone

if [ ! -d $fulldir/$dateformat ]; then

innobackupex --user=$user --password=$password --no-timestamp $fulldir/$dateformat >> $fulllog/fullbackup.log.$dateformat 2>&1 &

else

echo "don't backup database, because of directroy not found!" >> $logdir/error_full.log.$dateformat 2>&1 &

exit 1

fi# 每天一次的全增量(以全備份為基礎的增量),每兩個小時一次的增量備份(以全增量為基礎的增量)

10 1-23/2 * * * /root/incrementbackupdata.sh

#!/bin/bash

# define some variables

user=root

password=root

datefull=$(date +"%y-%m-%d")

datetime=$(date +"%y-%m-%d")

dateincre=$(date +"%y-%m-%d_%h-%m-%s")

direc=/mnt/backup

fulldir=$direc/full

increment=$direc/increment

logdir=/home/backuplog

incrementlog=$logdir/incrementlog

# the first incremental backup of a week's full backup.

if [ ! -d $increment/$datefull ]; then

mkdir -p $increment/$datefull

fullfilename=$(ls -lt $fulldir | sed -n 2p | awk '')

innobackupex --user=$user --password=$password --use-memory=1024mb --no-timestamp --incremental $increment/$datefull/$datetime --incremental-basedir=$fulldir/$fullfilename >> $incrementlog/increment.log.$datefull 2>&1 &

fi# incremental backups from the first incremental backups.

if [ -d $increment/$datefull/$datefull ]; then

cd $increment/$datefull

filename=$(ls -lt $increment/$datefull | sed -n 2p | awk '')

innobackupex --user=$user --password=$password --use-memory=1024mb --no-timestamp --incremental $increment/$datefull/$dateincre --incremental-basedir=$increment/$datefull/$filename>> $incrementlog/increment.log.$dateincre  2>&1 &

fi

innobackupex備份(全備 增量備)與恢復

安裝教程請檢視這篇文章 innobackupex備份選項 user 指定資料庫備份使用者 password 指定資料庫備份使用者密碼 port 指定資料庫埠 host 指定備份主機 socket 指定socket檔案路徑 databases 備份指定資料庫,多個空格隔開,如 databases db...

xtrabackup全備 增備 恢復

全備 innobackupex no timestamp defaults file path my.cnf data backup 20141106 增量1 innobackupex no timestamp defaults file path my.cnf incremental increm...

xtrabackup備份(全備,增備)

xtrabackup的介紹 mysql冷備 mysqldump mysql熱拷貝都無法實現對資料庫進行增量備份。在實際生產環境中增量備份是非常實用的,如果資料大於50g或100g,儲存空間足夠的情況下,可以每天進行完整備份,如果每天產生的資料量較大,需要定製資料備份策略。例如每週實用完整備份,周一到...