# How to restore incremental streaming backup with xbstream (getting file exists error)

**URL:** <https://forums.percona.com/t/how-to-restore-incremental-streaming-backup-with-xbstream-getting-file-exists-error/37477>\
**Category:** Percona XtraBackup\
**Created:** [April 3, 2025, 5:53pm UTC](https://forums.percona.com/t/how-to-restore-incremental-streaming-backup-with-xbstream-getting-file-exists-error/37477 "2025-04-03T17:53:58Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Justin\_Swanhart](https://sea1.discourse-cdn.com/flex019/user_avatar/forums.percona.com/justin_swanhart/32/20643_2.png) [@Justin\_Swanhart](https://forums.percona.com/u/Justin_Swanhart)\
**Post date:** [April 3, 2025, 5:53pm UTC](https://forums.percona.com/t/how-to-restore-incremental-streaming-backup-with-xbstream-getting-file-exists-error/37477/1 "2025-04-03T17:53:58Z")

</div>

I have taken an incremental backup of the database in streaming format using the --stream=xbstream and --incremental-lsn command line options.

When I restore my full backup, I run xtrabackup --prepare --apply-log-only --target-dir=/var/lib/mysql

Then I try the following:  
`$ cat /tmp/backup-incr-2025-04-03_3-xbstream.gz.aes256 | openssl enc -d -aes-256-cbc -pass file:mybackup.key| gzip -d | sudo xbstream -x -C`  
/var/lib/mysql  
\*\*\* WARNING : deprecated key derivation used.  
Using -iter or -pbkdf2 would be better.  
xbstream: Can’t create/write to file ‘./undo\_002.meta’ (OS errno 17 - File exists)  
xbstream: failed to create file.  
exit code: 1

This is the contents of my datadir after the failed xbstream -x -C:  
`$ ls /var/lib/mysql/_undo_ -lh  
-rw-r----- 1 root root 16M Apr 3 13:32 /var/lib/mysql/undo\_001  
-rw-r----- 1 root root 16K Apr 3 13:32 /var/lib/mysql/undo\_001.delta  
-rw-r----- 1 root root 69 Apr 3 13:32 /var/lib/mysql/undo\_001.meta  
-rw-r----- 1 root root 16M Apr 3 13:32 /var/lib/mysql/undo\_002  
-rw-r----- 1 root root 16K Apr 3 13:32 /var/lib/mysql/undo\_002.delta  
-rw-r----- 1 root root 69 Apr 3 13:32 /var/lib/mysql/undo\_002.meta

Am I supposed to extract the streaming backup to its own directory and prepare with --incremental-dir?

---

<div class="post-metadata">

**Author:** ![matthewb](https://sea1.discourse-cdn.com/flex019/user_avatar/forums.percona.com/matthewb/32/34_2.png) [@matthewb](https://forums.percona.com/u/matthewb)\
**Post date:** [April 4, 2025, 3:15pm UTC](https://forums.percona.com/t/how-to-restore-incremental-streaming-backup-with-xbstream-getting-file-exists-error/37477/2 "2025-04-04T15:15:22Z")

</div>

You need to extract the incremental backup to its own, separate, directory. From there, use xtrabackup --prepare, etc. An incremental backup is no different from any other, except less space used, so you must still prepare it, which merges the incremental into the original full backup.
