# Incremental restore fails

**URL:** https://forums.percona.com/t/incremental-restore-fails/21564
**Category:** Percona XtraBackup
**Created:** [April 21, 2023, 8:47pm UTC](https://forums.percona.com/t/incremental-restore-fails/21564 "2023-04-21T20:47:02Z")
**Posts on this page:** 6
**Page:** 1

<div class="post-metadata">

### Author: ![themactech](https://avatars.discourse-cdn.com/v4/letter/t/b2d939/32.png) [@themactech](https://forums.percona.com/u/themactech)
#### Post date: [April 21, 2023, 8:47pm UTC](https://forums.percona.com/t/incremental-restore-fails/21564/1 "2023-04-21T20:47:02Z")

</div>

Currently in testing on VMs, my backups are on a remote server

I have made a full backup in /MySQLBackups/  
I have made an incremental in /tmp/enc1/  
I have made an incremental in /tmp/enc2/

Full backup was done (Launched on the MySQL test server) with:

xtrabackup --backup --user=xtrabk --password-thepass --stream=xbstream | ssh root@remoteip “cat | xbstream -v -x -C /MySQLBackups”

I check the xtrabackup\_checkpoints to determine the last LSN on the backup: 4528497

Did the first incremental with:

xtrabackup --backup --user=xtrabk --password-thepass --incremental-lsb=4528498 --stream=xbstream | ssh root@remoteip “cat | xbstream -v -x -C /tmp/enc1”

I check the xtrabackup\_checkpoints to determine the last LSN on the backup: 4591652

Did the second incremental with:

xtrabackup --backup --user=xtrabk --password-thepass --incremental-lsb=4591653 --stream=xbstream | ssh root@remoteip “cat | xbstream -v -x -C /tmp/enc2”

My 3 directory have the backups on my remoteip machine

When I do the prepare on the full with:

xtrabackup --prepare --apply-log-only --target-dir=/MySQLBackups

It works, but when I do:

xtrabackup --prepare --apply-log-only --target-dir=/MySQLBackups --incremental-dir=/tmp/enc1

I get:

xtrabackup: error: This incremental backup seems not to be proper for the target.

The checkpoints for Full, enc1, enc2 are:

backup\_type = log-applied  
from\_lsn = 0  
to\_lsn = 4528488  
last\_lsn = 4528497  
compact = 0  
recover\_binlog\_info = 0  
flushed\_lsn = 4528497

backup\_type = incremental  
from\_lsn = 4528498  
to\_lsn = 4591643  
last\_lsn = 4591652  
compact = 0  
recover\_binlog\_info = 0  
flushed\_lsn = 4591652

backup\_type = incremental  
from\_lsn = 4591653  
to\_lsn = 4660765  
last\_lsn = 4660774  
compact = 0  
recover\_binlog\_info = 0  
flushed\_lsn = 4660774

This works under XtraBackup 8.0 and MySQL 8.0 but it is failing (as shown above) on XtraBackup 2.4 with MySQL 5.7

Am I doing something wrong in 2.4 or is there something different to do?

---

<div class="post-metadata">

### Author: ![Mauricio\_Cacho](https://sea1.discourse-cdn.com/flex019/user_avatar/forums.percona.com/mauricio_cacho/32/5859_2.png) [@Mauricio\_Cacho](https://forums.percona.com/u/Mauricio_Cacho)
#### Post date: [April 22, 2023, 1:17am UTC](https://forums.percona.com/t/incremental-restore-fails/21564/2 "2023-04-22T01:17:42Z")

</div>

Hi @themactech .  
Welcome to the Percona Forums.

I was checking in the [Docs for xtrabackup 2.4](https://docs.percona.com/percona-xtrabackup/2.4/backup_scenarios/incremental_backup.html#creating-an-incremental-backup) and there is this comment:

> `from_lsn` is the starting LSN of the backup and for incremental it has to be the same as `to_lsn` (if it is the last checkpoint) of the previous/base backup.

I can see you’re using the the `last_lsn` instead of `to_lsn`. Could you try with to\_lsn and se if that works?  
Also, I’m not sure if itis a typo, but the flag would be `--incremental-lsn`.

Give it a try and see if that helps.  
Best,  
Mauricio.

---

<div class="post-metadata">

### Author: ![themactech](https://avatars.discourse-cdn.com/v4/letter/t/b2d939/32.png) [@themactech](https://forums.percona.com/u/themactech)
#### Post date: [April 24, 2023, 2:34pm UTC](https://forums.percona.com/t/incremental-restore-fails/21564/3 "2023-04-24T14:34:50Z")

</div>

It was indeed a typo that is not in my terminal commands. I have just tried with setting the incremental-lsn to the value of “to\_lsn” and I still get the same error.

---

<div class="post-metadata">

### Author: ![themactech](https://avatars.discourse-cdn.com/v4/letter/t/b2d939/32.png) [@themactech](https://forums.percona.com/u/themactech)
#### Post date: [April 24, 2023, 3:02pm UTC](https://forums.percona.com/t/incremental-restore-fails/21564/4 "2023-04-24T15:02:06Z")

</div>

I just tried the same process but locally without streaming, and I also get the same error. Is there a way to get more verbose logs from XtraBackup? I also tried traditional incrementals locally and these work. So this seems to be related to increment-lsn. Again, I got this working on version 8 (both XtraBackup and. MySQL) but it fails on 2.4 and 5.7. In both cases I am running Debian 11.

---

<div class="post-metadata">

### Author: ![Marcelo\_Altmann](https://sea1.discourse-cdn.com/flex019/user_avatar/forums.percona.com/marcelo_altmann/32/11299_2.png) [@Marcelo\_Altmann](https://forums.percona.com/u/Marcelo_Altmann)
#### Post date: [April 24, 2023, 3:03pm UTC](https://forums.percona.com/t/incremental-restore-fails/21564/5 "2023-04-24T15:03:03Z")

</div>

Hi @themactech

I can see you have some mismatch in between to\_lsn from both base backup and from\_lsn on next backup:

```auto
#Full
backup_type = log-applied
from_lsn = 0
to_lsn = 4528488

#inc1
backup_type = incremental
from_lsn = 4528498 (full finished at 4528488)
to_lsn = 4591643

#inc2
backup_type = incremental
from_lsn = 4591653 (inc1 finished at 4591643)
to_lsn = 4660765

```

You should see exact same number from to\_lsn and from\_lsn when comparing base and incremental backups.

When using streaming, we advise to use `--extra-lsndir=/path/full_lsn` to save a copy of xtrabackup\_checkpoints and then later you just point to this folder as base for incremental.

Example:

```auto
#Full
xtrabackup --backup --user=xtrabk --password-thepass --stream=xbstream --extra-lsndir=/tmp/full_lsn | ssh root@remoteip “cat | xbstream -v -x -C /MySQLBackups”

#Inc1
xtrabackup --backup --user=xtrabk --password-thepass --stream=xbstream --incremental-basedir=/tmp/full_lsn --extra-lsndir=/tmp/inc1_lsn| ssh root@remoteip “cat | xbstream -v -x -C /tmp/enc1”

```

This helps with typos on the sequence number. If you still have issues, please send us a full copy of all your xtrabackup command (–backup from full, incs and --prepare)

---

<div class="post-metadata">

### Author: ![themactech](https://avatars.discourse-cdn.com/v4/letter/t/b2d939/32.png) [@themactech](https://forums.percona.com/u/themactech)
#### Post date: [April 24, 2023, 5:02pm UTC](https://forums.percona.com/t/incremental-restore-fails/21564/6 "2023-04-24T17:02:37Z")

</div>

The --extra-lsndir option works, thanks!
