# How to replicate InnoDB databases without locking?

**URL:** <https://forums.percona.com/t/how-to-replicate-innodb-databases-without-locking/2752>\
**Category:** Other MySQL® Questions\
**Created:** [June 11, 2013, 7:11pm UTC](https://forums.percona.com/t/how-to-replicate-innodb-databases-without-locking/2752 "2013-06-11T19:11:50Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![ylluminate](https://sea1.discourse-cdn.com/flex019/user_avatar/forums.percona.com/ylluminate/32/933_2.png) [@ylluminate](https://forums.percona.com/u/ylluminate)\
**Post date:** [June 11, 2013, 7:11pm UTC](https://forums.percona.com/t/how-to-replicate-innodb-databases-without-locking/2752/1 "2013-06-11T19:11:50Z")

</div>

We have a production database that needs to be backed up every 2 hours. There are two destinations actually; one is a staging server (on the same DB host) that we use for testing and the other is a copy of the database that we just need to make sure is in pristine backed up condition.

We want to do this efficiently, however we are finding that `mysqldump` locks the database such that the entire webapp hangs for ~15 minutes during a dump due to the size of the database.

How can we get around this and do so in the most efficient manner possible?

---

<div class="post-metadata">

**Author:** ![Serge\_Shakhov](https://avatars.discourse-cdn.com/v4/letter/s/6a8cbe/32.png) [@Serge\_Shakhov](https://forums.percona.com/u/Serge_Shakhov)\
**Post date:** [June 11, 2013, 8:34pm UTC](https://forums.percona.com/t/how-to-replicate-innodb-databases-without-locking/2752/2 "2013-06-11T20:34:51Z")

</div>

You can use Percona XtraBackup instead of mysqldump for creating backup online.

---

<div class="post-metadata">

**Author:** ![niljoshi](https://sea1.discourse-cdn.com/flex019/user_avatar/forums.percona.com/niljoshi/32/16889_2.png) [@niljoshi](https://forums.percona.com/u/niljoshi)\
**Post date:** [June 12, 2013, 12:07am UTC](https://forums.percona.com/t/how-to-replicate-innodb-databases-without-locking/2752/3 "2013-06-12T00:07:10Z")

</div>

Hi,

As Serge said, Percona Xtrabackup is the appropriate backup utility in your scenario where you can take backup without locking the tables. You can get more information here.

[URL][Percona XtraBackup](http://www.percona.com/doc/percona-xtrabackup/2.1/%5B/URL%5D)  
[URL][How-tos and Recipes](http://www.percona.com/doc/percona-xtrabackup/2.1/how-tos.html#howtos%5B/URL%5D)

---

<div class="post-metadata">

**Author:** ![ylluminate](https://sea1.discourse-cdn.com/flex019/user_avatar/forums.percona.com/ylluminate/32/933_2.png) [@ylluminate](https://forums.percona.com/u/ylluminate)\
**Post date:** [June 13, 2013, 1:35am UTC](https://forums.percona.com/t/how-to-replicate-innodb-databases-without-locking/2752/4 "2013-06-13T01:35:54Z")

</div>

So this does indeed seem to be the right solution, however I’m running into a problem simply trying to make my first backup. I created a folder called `backup` in my ~ folder. I then proceeded to craft the following command: `innobackupex --user=username password=user_password ~/backup`

Unfortunately after running this I get the following error:  
xtrabackup: Error: Please set parameter ‘datadir’  
innobackupex: Error: ibbackup child process has died at /usr/bin/innobackupex line 389.

What would you suggest doing to resolve this problem? Simply was trying to follow the steps here:  
[URL=“[How to setup a slave for replication in 6 simple steps with Percona XtraBackup](http://www.percona.com/doc/percona-xtrabackup/2.1/howtos/setting_up_replication.html)”][http://www.percona.com/doc/percona-x...plication.html[/URL]](http://www.percona.com/doc/percona-x...plication.html%5B/URL%5D)

---

<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:** [June 13, 2013, 5:21am UTC](https://forums.percona.com/t/how-to-replicate-innodb-databases-without-locking/2752/5 "2013-06-13T05:21:51Z")

</div>

Is ‘datadir’ option is set in my.cnf under mysqld section ? If not please set datadir parameter in my.cnf under mysqld section or if it’s already set and my.cnf exists on non-standard location you can pass --defaults-file=/path/to/my.cnf option to innobackupex command.

---

<div class="post-metadata">

**Author:** ![paultim374](https://avatars.discourse-cdn.com/v4/letter/p/ebca7d/32.png) [@paultim374](https://forums.percona.com/u/paultim374)\
**Post date:** [June 18, 2013, 1:54am UTC](https://forums.percona.com/t/how-to-replicate-innodb-databases-without-locking/2752/6 "2013-06-18T01:54:05Z")

</div>

Percona Xtrabackup is the appropriate backup utility in your scenario where you can take backup without locking the tables.

Are you interested in [Pass4sure C\_TFIN52\_66](http://www.pass4-sure.us/C_TFIN52_66-dumps.html)? Get our self paced [ECCOUNCIL](http://www.eccouncil.org/) and [Washington University in St. Louis](http://wustl.edu/) study packages to pass your [examsheets.com](http://examsheets.com) without any difficulty in [Arizona State University](http://en.wikipedia.org/wiki/Arizona_State_University) lsat.
