xtrabackup prepare - after dump or before restore?

by Denis   Last Updated August 10, 2018 13:06 PM

i have doubts about xtrabackup --apply-log. is there any difference when use it? should it be done right after dump or before restore (even few months later)? seems stupid, but maybe i missing something.

documentation says this:

Prepare a backup in BACKUP-DIR by applying the transaction log file named xtrabackup_logfile located in the same directory. Also, create new transaction logs. The InnoDB configuration is read from the file backup-my.cnf created by innobackupex when the backup was made.

thanks for help :)

Answers 3

found answer here. short is "you can do apply-log whenever you want", more useful information in link.

August 27, 2013 07:53 AM


You need to decide which protocol works best for you


Run --apply-log immediately after backup, and you would have the most currently full backup. You would not have to spend your recovery time applying applying logs at the time of a restore (especially at an actual disaster recovery event). Thus, recovery would be only focus at such a dire time.


This might work to your advantage if and only if you do not need the transactions that were accumulated after the point-in-time start of the backup. Such a situation would hardly make sense in a write-heavy environment.

Perhaps under these circumstances it would be better

  • Scheduled downtime
  • Small enough dataset
  • Acceptable window of time to backup (short time)
  • Additional backup of binary logs (extra insurance)


Whichever way one choose, make sure all the logs are good. If you apply the logs immediately, you'll know right then and there if the transaction logs are corrupt or not.

You also need to take into account how transaction-heavy the production system is. Why?

If the backup is recording incoming transactions as fast or faster than the backup process, then you have no choice but to go with PLAN B.

August 27, 2013 14:55 PM

The chief reason to use --apply-log until the time of restore is to support incremental backups.

If you make incremental backups, you would use --apply-log --redo-only each incremental backup, and then just before you restore, you do a final prepare with --apply-log.

Otherwise if you don't make incremental backups, there's no reason not to do --apply-log right after you make the back up. Then it's ready to restore on a moment's notice.

Bill Karwin
Bill Karwin
August 27, 2013 18:31 PM

Related Questions

xb_stream_read_chunk(): wrong chunk magic at offset 0x0

Updated November 18, 2017 10:06 AM