# Question about XtraBackup restore incremental

**URL:** <https://forums.percona.com/t/question-about-xtrabackup-restore-incremental/32566>\
**Category:** Percona XtraBackup\
**Created:** [August 25, 2024, 4:55am UTC](https://forums.percona.com/t/question-about-xtrabackup-restore-incremental/32566 "2024-08-25T04:55:40Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![CharlesR](https://avatars.discourse-cdn.com/v4/letter/c/54ee81/32.png) [@CharlesR](https://forums.percona.com/u/CharlesR)\
**Post date:** [August 25, 2024, 4:55am UTC](https://forums.percona.com/t/question-about-xtrabackup-restore-incremental/32566/1 "2024-08-25T04:55:40Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![warnersmith34](https://avatars.discourse-cdn.com/v4/letter/w/ea5d25/32.png) [@warnersmith34](https://forums.percona.com/u/warnersmith34)\
**Post date:** [August 25, 2024, 10:30am UTC](https://forums.percona.com/t/question-about-xtrabackup-restore-incremental/32566/2 "2024-08-25T10:30:36Z")

</div>

**Preparing Base and inc3**

This is the **correct** approach to restore the `inc3` backup.

1. **Prepare the base backup:**

```auto
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:**

```auto
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.

---

<div class="post-metadata">

**Author:** ![CharlesR](https://avatars.discourse-cdn.com/v4/letter/c/54ee81/32.png) [@CharlesR](https://forums.percona.com/u/CharlesR)\
**Post date:** [August 25, 2024, 1:11pm UTC](https://forums.percona.com/t/question-about-xtrabackup-restore-incremental/32566/3 "2024-08-25T13:11:16Z")

</div>

Hi,

Even though inc3 was backed up incrementally from inc2 ?

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

---

<div class="post-metadata">

**Author:** ![kedarpercona](https://sea1.discourse-cdn.com/flex019/user_avatar/forums.percona.com/kedarpercona/32/809_2.png) [@kedarpercona](https://forums.percona.com/u/kedarpercona)\
**Post date:** [August 26, 2024, 4:18am UTC](https://forums.percona.com/t/question-about-xtrabackup-restore-incremental/32566/4 "2024-08-26T04:18:33Z")

</div>

@CharlesR,

You need to work on all the incremental backups and in that order.  
Ref: [Incremental Backup - Percona XtraBackup](https://docs.percona.com/percona-xtrabackup/2.4/backup_scenarios/incremental_backup.html)

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
