Bug #53147 innobackup --copy-back overwrites the existing data contents without warning
Submitted: 26 Apr 2010 1:02 Modified: 19 Mar 2012 23:20
Reporter: Hema Sridharan Email Updates:
Status: Closed Impact on me:
None 
Category:MySQL Enterprise Backup Severity:S3 (Non-critical)
Version:3.5 OS:Any
Assigned to: Thava Alagu CPU Architecture:Any

[26 Apr 2010 1:02] Hema Sridharan
Description:
* Create databases, tables and load some data
* Perform backup using innobackup
* Perform some data manipulation operations in db1.t1 and db2.t2
* Execute innobackup --apply-logs
* Shutdown the server
* Perform restore using innobackup --copy-back option. Restart the server and we can notice that all the modified contents after backup is overwritten by restore. There should be a warning message issued when --copy-back is performed.
This will give users a caution to take backup after some additional data manipulation operations.

How to repeat:
CREATE DATABASE db1;
CREATE DATABASE db2;
CREATE TABLE db1.t1(id INT)ENGINE=INNODB;
CREATE TABLE db2.t2(a CHAR(10))ENGINE=INNODB;

INSERT INTO db1.t1 VALUES(1),(2),(3),(4);
INSERT INTO db2.t2 VALUES('a'),('b'),('c'),('d');

SELECT * FROM db1.t1;
SELECT * FROM db2.t2;

perl innobackup hema-inno.cnf mysql-test/backup/ --socket=/export/home2/tmp/mysql-5.1-ihb/mysql-test/var/tmp/mysqld.1.sock --user=root --ibbackup=/export/home2/tmp/mysql-5.1-ihb/ibbackup

INSERT INTO db1.t1 VALUES(5),(6);
DELETE FROM db2.t2 WHERE a='d';

perl innobackup --apply-log hema-inno.cnf /export/home2/tmp/mysql-5.1-ihb/mysql-test/backup/2010-04-21_23-35-15/ --ibbackup=/export/home2/tmp/mysql-5.1-ihb/ibbackup

Shutdown mysqld server
Perform copy-back 
./innobackup --copy-back hema-inno.cnf /export/home2/tmp/mysql-5.1-ihb/mysql-test/backup/2010-04-21_23-35-15/

Now start the server,

Check the data contents in db1.t1 and db2.t2

SELECT * FROM db1.t1;
id
1
2
3
4
SELECT * FROM db2.t2;
a
a
b
c
d

Note that although we got all the backed up contents for db1 and db2, there was no warning message about the overwriting of the contents.
[19 Mar 2012 23:20] John Russell
Added to changelog for 3.7.1: 

When running mysqlbackup with the copy-back option, now warnings are
displayed as existing files are overwritten.