Question about XtraBackup restore incremental

Hi,

I have the following backup directories:

/data/backups/base
/data/backups/inc1
/data/backups/inc2
/data/backups/inc3

Option 1: If I want to restore the inc3 backup, can I do it as follows: prepare the base and inc3 and then restore?

xtrabackup --prepare --apply-log-only --target-dir=/data/backups/base
xtrabackup --prepare --target-dir=/data/backups/base --incremental-dir=/data/backups/inc3

Option 2: Or do I need to prepare them all and then restore?

xtrabackup --prepare --apply-log-only --target-dir=/data/backups/base
xtrabackup --prepare --apply-log-only --target-dir=/data/backups/base --incremental-dir=/data/backups/inc2
xtrabackup --prepare --target-dir=/data/backups/base --incremental-dir=/data/backups/inc3

Preparing Base and inc3

This is the correct approach to restore the inc3 backup.

  1. Prepare the base backup:
Bash
xtrabackup --prepare --apply-log-only --target-dir=/data/backups/base

This step will create a consistent state of the database based on the base backup.

  1. Prepare the inc3 backup:
Bash
xtrabackup --prepare --target-dir=/data/backups/base --incremental-dir=/data/backups/inc3

This step will apply the changes from the inc3 backup to the prepared base.

Hi,

Even though inc3 was backed up incrementally from inc2 ?

xtrabackup --backup --target-dir=/data/backups/inc3 --incremental-basedir=/data/backups/inc2

@CharlesR,

You need to work on all the incremental backups and in that order.
Ref: Incremental Backup - Percona XtraBackup

To make complete restore apply the base backup with the --apply-log-only option:
xtrabackup --prepare --apply-log-only --target-dir=/data/backups/base

This prepares the base backup but does not finalize it, allowing incremental backups to be applied.

Apply the first incremental backup (inc1):
xtrabackup --prepare --apply-log-only --target-dir=/data/backups/base --incremental-dir=/data/backups/inc1

Apply the second incremental backup (inc2):
xtrabackup --prepare --apply-log-only --target-dir=/data/backups/base --incremental-dir=/data/backups/inc2

Apply the third incremental backup (inc3) and finalize:
xtrabackup --prepare --target-dir=/data/backups/base --incremental-dir=/data/backups/inc3

This step applies the final incremental changes from inc3 and finalizes the backup.

Thanks,
K