innobackupex failed to copy-back backup if destination dir is not empty

Bug #935847 reported by Igor Tverdovskiy on 2012-02-18
This bug affects 1 person
Affects Status Importance Assigned to Milestone
Percona XtraBackup
Igor Tverdovskiy
Igor Tverdovskiy
Igor Tverdovskiy

Bug Description


innobackupex requires empty destination dir in order to copy backup to it. I think this is wrong behaviour, because target dir could/should contain custom my.cnf or files. In such a case innobackupex should not consider non empty dir as error.

How to reproduce:
> ls -lh /var/
total 8,0K
-rw-rw---- 1 mysql mysql 69 Feb 18 23:08
-rw-r----- 1 mysql mysql 404 Feb 18 23:09 my.cnf

> sudo innobackupex --copy-back /var/tmps/backup
Original data directory is not empty! at /usr/bin/innobackupex line 574.

I have modified template which decides whether directory is empty or not.
--if ( ! scalar( grep { $_ ne "." && $_ ne ".." } readdir($dh)) == 0) {
++if ( ! scalar( grep { $_ ne "." && $_ ne ".." && $_ ne "my.cnf" && $_ ne ""} readdir($dh)) == 0) {

Related branches

Merged into lp:percona-xtrabackup/2.0 at revision 429
Stewart Smith (community): Approve on 2012-05-21
Valentine Gostev (community): Needs Fixing on 2012-02-19
Alexey Kopytov: Pending requested 2012-02-18
Changed in percona-xtrabackup:
assignee: nobody → Igor Tverdovskiy (igor-tverdovskiy)

also it should be backported to 1.6 release, changes are the same...

Valentine Gostev (longbow) wrote :

It is not very good practice to keep my.cnf and in datadir, much safer to keep it at external location, that's why explicit check for empty directory was added in

Anyway, if you need such exceptions current approach is not reasonable, I would recommend to add an option, which could accept a list of files to ignore.

Changed in percona-xtrabackup:
status: New → Incomplete
Alexey Kopytov (akopytov) wrote :

datadir is the default location for I don't see any problems with adding those exceptions, as XtraBackup does not backup those files, so it won't overwrite anything.

Changed in percona-xtrabackup:
status: Incomplete → Confirmed
Stewart Smith (stewart) on 2012-05-21
Changed in percona-xtrabackup:
status: Confirmed → Fix Committed
milestone: none → 2.0.1
importance: Undecided → Low
Stewart Smith (stewart) on 2012-05-21
Changed in percona-xtrabackup:
status: Fix Committed → Fix Released
To post a comment you must log in.
This report contains Public information  Edit
Everyone can see this information.

Other bug subscribers