# How can restore backup without doing Original data directory 'mysql'  empty.

**URL:** <https://forums.percona.com/t/how-can-restore-backup-without-doing-original-data-directory-mysql-empty/4641>\
**Category:** Percona XtraBackup\
**Created:** [January 1, 2016, 6:38am UTC](https://forums.percona.com/t/how-can-restore-backup-without-doing-original-data-directory-mysql-empty/4641 "2016-01-01T06:38:44Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Anandvastrad](https://avatars.discourse-cdn.com/v4/letter/a/c89c15/32.png) [@Anandvastrad](https://forums.percona.com/u/Anandvastrad)\
**Post date:** [January 1, 2016, 6:38am UTC](https://forums.percona.com/t/how-can-restore-backup-without-doing-original-data-directory-mysql-empty/4641/1 "2016-01-01T06:38:44Z")

</div>

Hello All,

I used restore DB backup script : [url][https://gist.github.com/DamianCaruso/931358?signup=true[/url]](https://gist.github.com/DamianCaruso/931358?signup=true%5B/url%5D)

As I am new to Xtrabackup I am facing some difficulties on how to restore an incremental backup. In more details:

Full backup:  
/home/navman/…/data/backups/full/2015-12-23\_23-52-31/

Incremental backup:  
/home/navman/…/data/backups/incr/2015-12-23\_23-52-31/2015-12-23\_23-52-41/  
/home/navman/…/data/backups/incr/2015-12-23\_23-52-31/2015-12-24\_22-00-03/  
/home/navman/…/data/backups/incr/2015-12-23\_23-52-31/2015-12-25\_22-00-02/

After preparing my incremental backups

I am facing below error. In MySQL I have multiple databases running in MySQL. So without stop MySQL and without doing Original data directory ‘/var/lib/mysql’ empty. How can restore db backup for single database?

innobackupex-1.5.1 failed:

---------- ERROR OUTPUT from innobackupex-1.5.1 ----------

InnoDB Backup Utility v1.5.1-xtrabackup; Copyright 2003, 2009 Innobase Oy  
and Percona LLC and/or its affiliates 2009-2013. All Rights Reserved.

This software is published under  
the GNU GENERAL PUBLIC LICENSE Version 2, June 1991.

Get the latest version of Percona XtraBackup, documentation, and help resources:  
[url][http://www.percona.com/xb/ubuntu[/url]](http://www.percona.com/xb/ubuntu%5B/url%5D)

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

innobackupex-1.5.1: Error: Original data directory ‘/var/lib/mysql’ is not empty! at /usr/b

---

<div class="post-metadata">

**Author:** ![hvo408](https://avatars.discourse-cdn.com/v4/letter/h/ecd19e/32.png) [@hvo408](https://forums.percona.com/u/hvo408)\
**Post date:** [January 4, 2016, 1:16pm UTC](https://forums.percona.com/t/how-can-restore-backup-without-doing-original-data-directory-mysql-empty/4641/2 "2016-01-04T13:16:32Z")

</div>

What options do you pass to the innobackupex command? Try adding --force-non-empty-directories.

---

<div class="post-metadata">

**Author:** ![Anandvastrad](https://avatars.discourse-cdn.com/v4/letter/a/c89c15/32.png) [@Anandvastrad](https://forums.percona.com/u/Anandvastrad)\
**Post date:** [January 13, 2016, 5:42am UTC](https://forums.percona.com/t/how-can-restore-backup-without-doing-original-data-directory-mysql-empty/4641/3 "2016-01-13T05:42:23Z")

</div>

I added

$INNOBACKUPEXFULL --defaults-file=$MYCNF --force-non-empty-directories --copy-back $FULLBACKUP \> $TMPFILE 2\>&1

How can resolve below error.?

## ~$ sudo sh restorebackup.sh /home/…/…/data/backups/full/2016-01-03\_23-55-24 /

restorebackup.sh: MySQL backup script  
started: Wed Jan 13 02:52:21 PST 2016

Restore 2016-01-03\_23-55-24

Preparing …

Restoring …  
stop: Unknown instance:  
mysql start/running, process 8092  
innobackupex-1.5.1 failed:

---------- ERROR OUTPUT from innobackupex-1.5.1 ----------

InnoDB Backup Utility v1.5.1-xtrabackup; Copyright 2003, 2009 Innobase Oy  
and Percona LLC and/or its affiliates 2009-2013. All Rights Reserved.

This software is published under  
the GNU GENERAL PUBLIC LICENSE Version 2, June 1991.

Get the latest version of Percona XtraBackup, documentation, and help resources:  
[http://www.percona.com/xb/ubuntu](http://www.percona.com/xb/ubuntu)

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

innobackupex-1.5.1: Starting to copy InnoDB system tablespace  
innobackupex-1.5.1: in ‘/home/…/…/data/backups/full/2016-01-03\_23-55-24’  
innobackupex-1.5.1: back to original InnoDB data directory ‘/var/lib/mysql’  
innobackupex-1.5.1: Error: Cannot overwrite file: /var/lib/mysql/ibdata1 at /usr/bin/innobackupex-1.5.1 line 2128.

---

<div class="post-metadata">

**Author:** ![Anandvastrad](https://avatars.discourse-cdn.com/v4/letter/a/c89c15/32.png) [@Anandvastrad](https://forums.percona.com/u/Anandvastrad)\
**Post date:** [January 22, 2016, 3:22am UTC](https://forums.percona.com/t/how-can-restore-backup-without-doing-original-data-directory-mysql-empty/4641/4 "2016-01-22T03:22:39Z")

</div>

Before restore, I have 1 full backup and 3 incremental backups and 2nd Full backup,Newly data added in every backup. After executing restore script on 1st Full backup I am getting all data to till 2nd full backup not to till 1st full backup. May I know why this behavior happening in my script. Any suggestion.
