berikut ini adalah script yang dapat digunakan untuk membackup db menggunakan percona xtrabackup (innobackupex)

ada dua script yaitu untuk full dan incremental backup.

full backup dijalankan setiap dini hari antara pukul 00:00 atau 01:00
incremental backup jalankan bisa perjam atau sesuai keinginan

incremental backup

#!/bin/sh

TMPFILE="/tmp/innobackupex-runner.$$.tmp"
USEROPTIONS="--user=bac_user --password=Password"
FILTERTABLES="--include=.*[.].*"
BACKDIR=/var/lib/backup_db
BASEBACKDIR=$BACKDIR/base
INCRBACKDIR=$BACKDIR/incr

# Find latest backup directory
LATEST=`find $BASEBACKDIR -mindepth 1 -maxdepth 1 -type d -printf "%P\n" | sort -nr | head -1`

#Create incremental Backup
/usr/bin/innobackupex $USEROPTIONS $FILTERTABLES --incremental $INCRBACKDIR --incremental-basedir=$BASEBACKDIR/$LATEST > $TMPFILE 2>&1

full backup

#!/bin/sh

TMPFILE="/tmp/innobackupex-runner.$$.tmp"
USEROPTIONS="--user=bac_user --password=Password"
FILTERTABLES="--include=.*[.].*"
BACKDIR=/var/lib/backup_db
BASEBACKDIR=$BACKDIR/base

#Create a new full backup
/usr/bin/innobackupex $USEROPTIONS $FILTERTABLES --no-lock $BASEBACKDIR > $TMPFILE 2>&1

silahkan dicoba, semoga bermanfaat.

perbaiki saja jika dirasa dibutuhkan

source : https://gist.github.com/selwin/1131224

Advertisements