# Can't restore partial backup

**URL:** <https://forums.percona.com/t/cant-restore-partial-backup/3770>\
**Category:** Percona XtraBackup\
**Created:** [September 25, 2014, 1:49am UTC](https://forums.percona.com/t/cant-restore-partial-backup/3770 "2014-09-25T01:49:46Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![apirasak](https://sea1.discourse-cdn.com/flex019/user_avatar/forums.percona.com/apirasak/32/1037_2.png) [@apirasak](https://forums.percona.com/u/apirasak)\
**Post date:** [September 25, 2014, 1:49am UTC](https://forums.percona.com/t/cant-restore-partial-backup/3770/1 "2014-09-25T01:49:46Z")

</div>

I’m a newbie and practice in Percona xtrabackup tools  
I try backup database by  
innobackupex --defaults-file=/etc/my.cnf --user=bkpuser --password=s3cret --database=“mydatabase” /home/mysql/Backup/  
status completed.

innobackupex --apply-log --export /home/mysql/Backup/2014-09-24\_12-23-19  
status completed

I try to restore but got error message.  
innobackupex --copy-back /home/mysql/Backup/2014-09-24\_12-23-19  
innobackupex: Error: Original data directory ‘/database/data’ is not empty! at /usr/local/xtrabackup/bin/innobackupex line 2162.

Note: in /database/data have more than one databases are running.  
How can I restore database??? I want to restore only one database.

Thank you.

---

<div class="post-metadata">

**Author:** ![mirfan](https://sea1.discourse-cdn.com/flex019/user_avatar/forums.percona.com/mirfan/32/16890_2.png) [@mirfan](https://forums.percona.com/u/mirfan)\
**Post date:** [September 25, 2014, 2:34am UTC](https://forums.percona.com/t/cant-restore-partial-backup/3770/2 "2014-09-25T02:34:52Z")

</div>

Please follow the steps below for partial backup.

Take partial backup where “mydb” is the intended database which you need to backup.

1. $ mysql --skip-column-names -e “SELECT CONCAT(table\_schema,‘.’,table\_name) FROM information\_schema.tables WHERE table\_schema = ‘mydb’;” \> /path/to/tables.txt  
$ innobackupex --tables-file=/path/to/tables.txt /path/to/backup/

You can read further here about partial backup [URL][Percona XtraBackup](http://www.percona.com/doc/percona-xtrabackup/2.2/innobackupex/partial_backups_innobackupex.html%5B/URL%5D)

Apply log with --export option. This will create prepare each table with .exp and .ibd files.  
2) innobackupex --apply-log --export /path/to/backup/

On importing server create tables manually which need to restore  
3) CREATE TABLE test …

Discard the tablespace  
4) ALTER TABLE test DISCARD TABLESPACE;

Copy the .exp & .ibd files to the datadir where need to import  
5) ALTER TABLE test IMPORT TABLESPACE;

It’s mandatory that your source server from where you taking the backup have innodb\_file\_per\_table option enabled and the importing server should have innodb\_file\_per\_table and innodb\_expand\_import enabled (only supported for Percona Server). You can read more about it here [url][Percona XtraBackup](http://www.percona.com/doc/percona-xtrabackup/2.1/innobackupex/importing_exporting_tables_ibk.html#importing-tables%5B/url%5D)

Further, If you are using MySQL/Percona Server version 5.6 then you need to use Transportable Tablespace as mentioned here [url][http://dev.mysql.com/doc/refman/5.6/en/tablespace-copying.html[/url]](http://dev.mysql.com/doc/refman/5.6/en/tablespace-copying.html%5B/url%5D)

Hope that helps.

---

<div class="post-metadata">

**Author:** ![willamowius](https://avatars.discourse-cdn.com/v4/letter/w/838e76/32.png) [@willamowius](https://forums.percona.com/u/willamowius)\
**Post date:** [December 12, 2018, 10:36am UTC](https://forums.percona.com/t/cant-restore-partial-backup/3770/3 "2018-12-12T10:36:09Z")

</div>

Does the 2nd invocation of innobackupex with --apply-log --export have to be done at the time of the backup ? Or can it be done when the backup needs to be restored ?

Using the full path (including the date) is not very handy to aoutomate when doing backups.
