# Cannot prepare partial database backup

**URL:** <https://forums.percona.com/t/cannot-prepare-partial-database-backup/8666>\
**Category:** Percona XtraBackup\
**Created:** [January 7, 2021, 2:09am UTC](https://forums.percona.com/t/cannot-prepare-partial-database-backup/8666 "2021-01-07T02:09:15Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![Churchill](https://avatars.discourse-cdn.com/v4/letter/c/e0b2c6/32.png) [@Churchill](https://forums.percona.com/u/Churchill)\
**Post date:** [January 7, 2021, 2:09am UTC](https://forums.percona.com/t/cannot-prepare-partial-database-backup/8666/1 "2021-01-07T02:09:15Z")

</div>

Good day,

I’m fairly new with Percona Xtrabackup, and I’m having a difficulty restoring a backup. First of, I’ve created a script to run a partial backup every x hours. Here’s the backup command I’m using in my script:

innobackupex --include=$database $backupdir --host=$host --user=$username --password=$password --stream=tar | gzip → $backupdir"$database-$(date +%Y-%m-%d).tar.gz"

I could say my backup is working since I do see the backup file being created and when I extract the backup, it contains \*ibd file. Now, the problem is that when I try to prepare the backup, I get this:

innobackupex --apply-log --export /backups/xtrabackup-data/backup/12122020/  
xtrabackup: recognized server arguments:  
xtrabackup: recognized client arguments:  
210107 02:05:00 innobackupex: Starting the apply-log operation

IMPORTANT: Please check that the apply-log run completes successfully.  
At the end of a successful apply-log run innobackupex  
prints “completed OK!”.

innobackupex version 2.4.20 based on MySQL server 5.7.26 Linux (x86\_64) (revision id: c8b4056)  
xtrabackup: auto-enabling --innodb-file-per-table due to the --export option  
xtrabackup: cd to /backups/xtrabackup-data/backup/12122020/  
xtrabackup: Error: cannot open ./xtrabackup\_checkpoints  
xtrabackup: Error: failed to read metadata from ‘./xtrabackup\_checkpoints’

I look into the files extracted, but I don’t see a file called xtrabackup\_checkpoints. All I have are \*.ibd files and an ibdata1.

Here’s my percona xtrabackup version:

innobackupex --version  
xtrabackup: recognized server arguments: --datadir=/data/mysql --innodb\_flush\_log\_at\_trx\_commit=0 --innodb\_flush\_method=O\_DIRECT --innodb\_log\_buffer\_size=32M --innodb\_read\_io\_threads=32 --innodb\_write\_io\_threads=16 --innodb\_log\_file\_size=1G --innodb\_buffer\_pool\_size=10G --open\_files\_limit=50000  
innobackupex version 2.4.20 Linux (x86\_64) (revision id: c8b4056)

Any help is highly appreciated. Also, Is it possible to restore a partial backup without preparing? Thank you

---

<div class="post-metadata">

**Author:** ![CTutte](https://sea1.discourse-cdn.com/flex019/user_avatar/forums.percona.com/ctutte/32/1341_2.png) [@CTutte](https://forums.percona.com/u/CTutte)\
**Post date:** [January 7, 2021, 1:15pm UTC](https://forums.percona.com/t/cannot-prepare-partial-database-backup/8666/2 "2021-01-07T13:15:13Z")

</div>

Hi Churchill,

If the backup prints “Completed OK!” at the end, it’s very likely the backup is not corrupt.  
I have tested on my side with same command as you, and after decompressing the backup, file “xtrabackup\_checkpoints” does exist on my backup folder. Can you double check if you had enough disk space to decompress the backup? Otherwise the untar command might have executed partially. Also, can you double check that path “/backups/xtrabackup-data/backup/12122020/” is indeed the correct path of the uncompressed backup ?

What preparing does is applying redo log and rolling back unfinished transactions at the time the backup was taken, which is essentially doing crash recovery. It’s suggested to prepare the backup before restoring , but otherwise crash recovery would be run at startup time after restoring the unprepared backup.

Do note that you are using --export flag, which means that you are trying to import individual tables: [The innobackupex Option Reference](https://www.percona.com/doc/percona-xtrabackup/2.3/innobackupex/innobackupex_option_reference.html#cmdoption-innobackupex-export)  
If you restore a partial backup, then table dictionary + only included schemas/tables will be restored, and since table dictionary was overwriten, any other table/schema that was not restored will be lost. I.e you cannot merge a partial backup with an existing instance this way. If you wish to restore a partial backup, you should import 1 tablespace at a time as described above and as shown in [Restoring Individual Tables](https://www.percona.com/doc/percona-xtrabackup/2.3/xtrabackup_bin/restoring_individual_tables.html)

Last, innobackupex program is deprecated. Please switch to xtrabackup to avoid any unexpected behavior.

---

<div class="post-metadata">

**Author:** ![Churchill](https://avatars.discourse-cdn.com/v4/letter/c/e0b2c6/32.png) [@Churchill](https://forums.percona.com/u/Churchill)\
**Post date:** [January 8, 2021, 10:31am UTC](https://forums.percona.com/t/cannot-prepare-partial-database-backup/8666/3 "2021-01-08T10:31:04Z")

</div>

Thanks for the very informative response @CTutte. I do have a lot of disk space, so I believe that everything has been extracted. I’ve also checked /backups/xtrabackup-data/backup/12122020/ and it’s the correct path of the uncompressed backup. Unfortunately, due to urgency, I had to find a different approach, and the instructions in [Restoring Individual Tables](https://www.percona.com/doc/percona-xtrabackup/2.3/xtrabackup_bin/restoring_individual_tables.html) allowed me to restore my backup without the need to prepare. Do you think this is the best method to restore my partial backups?

---

<div class="post-metadata">

**Author:** ![CTutte](https://sea1.discourse-cdn.com/flex019/user_avatar/forums.percona.com/ctutte/32/1341_2.png) [@CTutte](https://forums.percona.com/u/CTutte)\
**Post date:** [January 8, 2021, 12:17pm UTC](https://forums.percona.com/t/cannot-prepare-partial-database-backup/8666/4 "2021-01-08T12:17:05Z")

</div>

Hi again,

if you expect to merge a partial bakcup with more data, you need to either

- restore the partial backup first, then do a logical restore of the rest of the data
- having the rest of the data and restore your physical backup (pxb) and/or some of the tables only, then you need to import tablespace one at a time

Due to data dictionary handled internally by MySQL, it’s not possible to merge two (or more) physical backups and/or existing instance with an existing backup. Keeping this in mind you should plan ahead the restore procedure and script table importing, and/or reconsider going with full backups instead of partial ones.

Regards

---

<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:** [January 8, 2021, 9:28pm UTC](https://forums.percona.com/t/cannot-prepare-partial-database-backup/8666/5 "2021-01-08T21:28:34Z")

</div>

Just wanted to chime in that you should stop using innobackupex and switch to xtrabackup directly. Most commands just map back to xtrabackup anyways. Our documentation is out of date here but we do recommend this.
