MySQL Backups – Full vs Incremental with innobackupex

backupMySQLpercona

So I'm implementing a backup strategy for our project and came across some text which I need absolute clarification, false positives are the death nell of IT.

I am looking to do your typical backup strategy, weekly full back-up with daily incremental backups. Here's the rub:

According to the docs, when doing a full backup you have to 'prep' it, which is to run all uncommitted transactions etc. You can prep the backup by using the innobackupex –apply-log /path/to/BACKUP-DIR command.

But according to these docs, if you do an incremental backup, you have to 'prep' it differently, using the innobackupex –apply-log –redo-only BASE-DIR command.

My plan is to write a cronjob to do a full backup on Sunday @ 12:01am, and an incremental on M-Sa @ 12:01 am. So my question is, should the cronjob prep every backup with the –redo-only flag, to ensure that full backup can be merged with following incremental backups?

Best Answer

No, you don't need to prep every backup. You only need to create the full backup on Sunday and then create the incrementals from Monday to Saturday.

Full:

innobackupex --user=USER --password=PASSWORD /path/to/backup/dir/

Incr:

innobackupex --incremental /path/to/inc/mon --incremental-basedir=$FULLBACKUP --user=USER --password=PASSWORD

innobackupex --incremental /path/to/inc/tue --incremental-basedir=/path/to/inc/mon --user=USER --password=PASSWORD

The prepare phase (--apply-log) is only needed when you restore the backup.