Merge lp:~igor-tverdovskiy/percona-xtrabackup/move-back_opt into lp:percona-xtrabackup/2.0

Proposed by Igor Tverdovskiy
Status: Rejected
Rejected by: Alexey Kopytov
Proposed branch: lp:~igor-tverdovskiy/percona-xtrabackup/move-back_opt
Merge into: lp:percona-xtrabackup/2.0
Diff against target: 246 lines (+92/-13) (has conflicts)
2 files modified
innobackupex (+59/-13)
test/t/bug803636.sh (+33/-0)
Text conflict in innobackupex
To merge this branch: bzr merge lp:~igor-tverdovskiy/percona-xtrabackup/move-back_opt
Reviewer Review Type Date Requested Status
Alexey Kopytov (community) Needs Resubmitting
Laurynas Biveinis (community) Needs Fixing
Stewart Smith (community) Needs Fixing
Review via email: mp+93711@code.launchpad.net

Description of the change

move-back opt was added. It does the same as copy-back, but moves files. - useful if not much of free disk space is available.

To post a comment you must log in.
Revision history for this message
Stewart Smith (stewart) wrote :

The only thing missing here is a test case. It will be fairly easy to write one though. Check out some of the ib_ tests in test/t - they're shell scripts that use a bunch of helper functions provided by the test suite.

review: Needs Fixing
Revision history for this message
Vojtech Kurka (vojtech-kurka) wrote :

Please how is the status of this patch? When recovering a compressed backup of 1TB of data, it's not acceptable to wait for copying the data, it can take hours - moving is the only option.
Thank you, Vojtech

Revision history for this message
Stewart Smith (stewart) wrote :

> Please how is the status of this patch? When recovering a compressed backup of
> 1TB of data, it's not acceptable to wait for copying the data, it can take
> hours - moving is the only option.
> Thank you, Vojtech

If you're able to supply a test case, we can merge it a lot quicker.

394. By Igor Tverdovskiy

changes applied to the latest innobackupex, test case added

395. By Igor Tverdovskiy

test case added

Revision history for this message
Igor Tverdovskiy (igor-tverdovskiy) wrote :
Download full text (4.3 KiB)

Hi All,

> > Please how is the status of this patch? When recovering a compressed backup
> of
> > 1TB of data, it's not acceptable to wait for copying the data, it can take
> > hours - moving is the only option.
> > Thank you, Vojtech
>
> If you're able to supply a test case, we can merge it a lot quicker.

Test case has been added (bug803636.sh)

All cases are passed or skipped:

> sudo ./run.sh -d /usr
2012-08-29 16:56:50: run.sh: Stopping server with id=1...
2012-08-29 16:56:51: run.sh: Server with id=1 has been stopped
Running against MySQL 5.1.52-log (InnoDB )
Using 'xtrabackup_51' as xtrabackup binary

========================================================================

t/bug1002688.sh [passed]
t/bug1022562.sh [passed]
t/bug1028949.sh [skipped] Requires InnoDB plugin or XtraDB
t/bug483827.sh [passed]
t/bug489290.sh [passed]
t/bug514068.sh [passed]
t/bug606981.sh [passed]
t/bug722638.sh [passed]
t/bug723097.sh [passed]
t/bug723318.sh [passed]
t/bug729843.sh [passed]
t/bug733651.sh [passed]
t/bug759225.sh [skipped] Requires XtraDB
t/bug759701.sh [passed]
t/bug766033.sh [passed]
t/bug766607.sh [passed]
t/bug803636.sh [passed]
t/bug810269.sh [skipped] Requires InnoDB plugin or XtraDB
t/bug817132.sh [skipped] Requires xtradb51
t/bug884737.sh [passed]
t/bug891496.sh [passed]
t/bug932623.sh [passed]
t/bug972169.sh [passed]
t/bug976945.sh [skipped] Requires XtraDB
t/bug977101.sh [passed]
t/bug977652.sh [skipped] Requires qpress to be installed
t/bug983685.sh [passed]
t/bug983695.sh [skipped] Requires qpress to be installed
t/bug983720_galerainfo.sh [skipped] Requires WSREP enabled
t/bug983720_lrudump.sh [skipped] Requires XtraDB
t/bug989397.sh [passed]
t/bug996493.sh [passed]
t/bug999750.sh [skipped] Requires InnoDB plugin or XtraDB
t/ib_binlog_info.sh [passed]
t/ib_csm_csv.sh [passed]
t/ib_empty_dir.sh [passed]
t/ib_incremental.sh [passed]
t/ib_lru_dump_basic.sh [skipped] Requires XtraDB
t/ib_lru_dump_rsync.sh [skipped] Requires XtraDB
t/ib_lru_dump_stream.sh [skipped] Requires XtraDB
t/ib_rsync.sh [passed]
t/ib_slave_info.sh [passed]
t/ib_specialchar.sh [passed]
t/ib_stream_compress.sh [skipped] ...

Read more...

Revision history for this message
Igor Tverdovskiy (igor-tverdovskiy) wrote :

PS: I have committed the latest innobackupex file with my changes.

Revision history for this message
Laurynas Biveinis (laurynas-biveinis) wrote :

Unfortunately there are merge conflicts against the current 2.0 trunk, see the diff below.

review: Needs Fixing
Revision history for this message
Igor Tverdovskiy (igor-tverdovskiy) wrote :

> Unfortunately there are merge conflicts against the current 2.0 trunk, see the
> diff below.

Okay, I'm going to add modifications to innobackupex from lp:percona-xtrabackup/2.0 branch. I'll be back soon.

396. By Igor Tverdovskiy

option added to 2.0 trunk

Revision history for this message
Igor Tverdovskiy (igor-tverdovskiy) wrote :

done please check

Revision history for this message
Alexey Kopytov (akopytov) wrote :

There's still one conflict in the pod section of innobackupex:

176 -innobackupex --copy-back [--defaults-file=MY.CNF] [--defaults-group=GROUP-NAME] BACKUP-DIR
177 +<<<<<<< TREE
178 +innobackupex --copy-back [--defaults-file=MY.CNF] [--defaults-group=GROUP-NAME] BACKUP-DIR
179 +=======
180 +innobackupex --copy-back [--defaults-file=MY.CNF] [--defaults-group=GROUP-NAME] BACKUP-DIR
181 + --move-back [--defaults-file=MY.CNF] [--defaults-group=GROUP-NAME] BACKUP-DIR
182 +>>>>>>> MERGE-SOURCE

I would create a separate line in the help text, rather than add --move-back to the existing one describing the --copy-back synopsis, i.e.:

innobackupex --copy-back [--defaults-file=MY.CNF] [--defaults-group=GROUP-NAME] BACKUP-DIR

innobackupex --move-back [--defaults-file=MY.CNF] [--defaults-group=GROUP-NAME] BACKUP-DIR

review: Needs Fixing
397. By Igor Tverdovskiy

move-back hepl text has been separated

Revision history for this message
Igor Tverdovskiy (igor-tverdovskiy) wrote :

committed please check

Revision history for this message
Laurynas Biveinis (laurynas-biveinis) wrote :

> committed please check

There are still merge conflicts shown in the diff: around lines 58 and 176.

review: Needs Fixing
Revision history for this message
Igor Tverdovskiy (igor-tverdovskiy) wrote :

> > committed please check
>
> There are still merge conflicts shown in the diff: around lines 58 and 176.

Hi,

I have looked through, however do not see any conflicts there.. Just a single new line of code was added in both cases.

Revision history for this message
Alexey Kopytov (akopytov) wrote :

Igor,

You can find the remaining conflicts if you look for "<<<" in the Preview Diff. But don't worry, I'll fix it myself in a separate MP along with some minor edits to the patch. Closing this MP.

review: Needs Resubmitting
Revision history for this message
Igor Tverdovskiy (igor-tverdovskiy) wrote :

I saw these conflicts <<<, however I do not understand what is wrong there... One line was replaced by two lines of code...

Revision history for this message
Laurynas Biveinis (laurynas-biveinis) wrote :

Probably the reason for all these conflicts is that the submitted branch has been branched off XtraBackup trunk a long time ago, so it is very likely they have diverged.

Revision history for this message
Igor Tverdovskiy (igor-tverdovskiy) wrote :

It has been branched on 2nd of September from lp:percona-xtrabackup/2.0 branch. Is this branch wrong? I should have used another one?

thanks

Revision history for this message
Laurynas Biveinis (laurynas-biveinis) wrote :

It does not seem to be branched off lp:percona-xtrabackup/2.0: the last parent branch commit on your branch is rev 392, dated in February. lp:percona-xtrabackup/2.0 currently is at rev 464, made on August 22.

Revision history for this message
Igor Tverdovskiy (igor-tverdovskiy) wrote :

Well my branch is pretty old because I have added this option in February, however on 2nd September I downloaded innobackupex from 2.0 branch, added my code, replaced old innobackupex in my branch with new one and committed changes.

Revision history for this message
Laurynas Biveinis (laurynas-biveinis) wrote :

I see, that probably confused bzr into thinking that there are conflicts. One of the correct procedures would be to branch freshly from recent 2.0 and make your changes - this might come handy in the future, as Alexey said he will take care of this MP.

Thanks for working on this.

Revision history for this message
Igor Tverdovskiy (igor-tverdovskiy) wrote :

ok, thanks for clarification

Revision history for this message
Laurynas Biveinis (laurynas-biveinis) wrote :

Unmerged revisions

397. By Igor Tverdovskiy

move-back hepl text has been separated

396. By Igor Tverdovskiy

option added to 2.0 trunk

395. By Igor Tverdovskiy

test case added

394. By Igor Tverdovskiy

changes applied to the latest innobackupex, test case added

393. By Igor Tverdovskiy

added new option --move-back, just the same as --copy-back, but moves files instead.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'innobackupex'
--- innobackupex 2012-08-02 12:38:15 +0000
+++ innobackupex 2012-09-02 15:43:18 +0000
@@ -72,6 +72,7 @@
72my $option_apply_log = '';72my $option_apply_log = '';
73my $option_redo_only = '';73my $option_redo_only = '';
74my $option_copy_back = '';74my $option_copy_back = '';
75my $option_move_back = '';
75my $option_include = '';76my $option_include = '';
76my $option_databases = '';77my $option_databases = '';
77my $option_tables_file = '';78my $option_tables_file = '';
@@ -217,6 +218,8 @@
217my $dst_name;218my $dst_name;
218my $win = ($^O eq 'MSWin32' ? 1 : 0);219my $win = ($^O eq 'MSWin32' ? 1 : 0);
219my $CP_CMD = ($win eq 1 ? "copy /Y" : "cp -p");220my $CP_CMD = ($win eq 1 ? "copy /Y" : "cp -p");
221my $MV_CMD = ($win eq 1 ? "move /Y" : "mv -f");
222my $MV_CP_CMD = '';
220my $xtrabackup_binary_file = 'xtrabackup_binary';223my $xtrabackup_binary_file = 'xtrabackup_binary';
221my $xtrabackup_pid_file = 'xtrabackup_pid';224my $xtrabackup_pid_file = 'xtrabackup_pid';
222my %rsync_files_hash;225my %rsync_files_hash;
@@ -237,7 +240,7 @@
237print_version();240print_version();
238241
239# initialize global variables and perform some checks242# initialize global variables and perform some checks
240if ($option_copy_back) {243if ($option_copy_back || $option_move_back) {
241 $option_ibbackup_binary = 'xtrabackup' if ($option_ibbackup_binary eq 'autodetect');244 $option_ibbackup_binary = 'xtrabackup' if ($option_ibbackup_binary eq 'autodetect');
242} elsif ($option_apply_log) {245} elsif ($option_apply_log) {
243 # Read XtraBackup version from backup dir246 # Read XtraBackup version from backup dir
@@ -280,6 +283,9 @@
280if ($option_copy_back) {283if ($option_copy_back) {
281 # copy files from backup directory back to their original locations284 # copy files from backup directory back to their original locations
282 copy_back();285 copy_back();
286} elsif ($option_move_back) {
287 # move files from backup directory back to their original locations
288 move_back();
283} elsif ($option_apply_log) {289} elsif ($option_apply_log) {
284 # expand data files in backup directory by applying log files to them290 # expand data files in backup directory by applying log files to them
285 apply_log();291 apply_log();
@@ -627,11 +633,25 @@
627}633}
628634
629#635#
636# move_back subroutine uses copy_back subroutine to move data and index files
637# from backup directory back to their original locations.
638#
639sub move_back {
640 my $move = 'yes';
641 copy_back($move);
642}
643
644#
630# copy_back subroutine copies data and index files from backup directory 645# copy_back subroutine copies data and index files from backup directory
631# back to their original locations.646# back to their original locations.
632#647#
633sub copy_back {648sub copy_back {
634 my $orig_datadir = get_option(\%config, $option_defaults_group, 'datadir');649<<<<<<< TREE
650 my $orig_datadir = get_option(\%config, $option_defaults_group, 'datadir');
651=======
652 my($move) = @_;
653 my $orig_datadir = get_option(\%config, $option_defaults_group, 'datadir');
654>>>>>>> MERGE-SOURCE
635 my $orig_ibdata_dir = 655 my $orig_ibdata_dir =
636 get_option(\%config, $option_defaults_group, 'innodb_data_home_dir');656 get_option(\%config, $option_defaults_group, 'innodb_data_home_dir');
637 my $orig_innodb_data_file_path = 657 my $orig_innodb_data_file_path =
@@ -647,6 +667,14 @@
647 my $compressed_data_file = '.*\.ibz$';667 my $compressed_data_file = '.*\.ibz$';
648 my $file;668 my $file;
649 my $backup_innodb_data_file_path;669 my $backup_innodb_data_file_path;
670
671 # check whether files should be copied or moved to dest directory
672 if ($move eq 'yes') {
673 $MV_CP_CMD = $MV_CMD;
674 } else {
675 $MV_CP_CMD = $CP_CMD;
676 }
677
650 # check that original data directories exist and they are empty678 # check that original data directories exist and they are empty
651 if_directory_exists_and_empty($orig_datadir, "Original data");679 if_directory_exists_and_empty($orig_datadir, "Original data");
652 if_directory_exists_and_empty($orig_ibdata_dir, "Original InnoDB data");680 if_directory_exists_and_empty($orig_ibdata_dir, "Original InnoDB data");
@@ -678,7 +706,8 @@
678 Die "Backup data file '$backup_dir/$filename' does not exist, but "706 Die "Backup data file '$backup_dir/$filename' does not exist, but "
679 . "its compressed copy '${path}.ibz' exists. Check "707 . "its compressed copy '${path}.ibz' exists. Check "
680 . "that you have run '$innobackup_script --apply-log --uncompress "708 . "that you have run '$innobackup_script --apply-log --uncompress "
681 . "...' before attempting '$innobackup_script --copy-back ...' !";709 . "...' before attempting '$innobackup_script --copy-back ...' "
710 . "...' or '$innobackup_script --move-back ...' !";
682 } else {711 } else {
683 Die "Backup data file '$backup_dir/$filename' does not exist.";712 Die "Backup data file '$backup_dir/$filename' does not exist.";
684 }713 }
@@ -706,8 +735,8 @@
706 print STDERR "$prefix Copying file '$backup_dir/$filename'\n";735 print STDERR "$prefix Copying file '$backup_dir/$filename'\n";
707 $src_name = escape_path("$backup_dir/$filename");736 $src_name = escape_path("$backup_dir/$filename");
708 $dst_name = escape_path("$orig_ibdata_dir/$path");737 $dst_name = escape_path("$orig_ibdata_dir/$path");
709 system("$CP_CMD \"$src_name\" \"$dst_name\"")738 system("$MV_CP_CMD \"$src_name\" \"$dst_name\"")
710 and Die "Failed to copy file '$filename': $!";739 and Die "Failed to copy/move file '$filename': $!";
711 }740 }
712741
713 # copy InnoDB log files to original InnoDB log directory742 # copy InnoDB log files to original InnoDB log directory
@@ -721,8 +750,8 @@
721 print STDERR "$prefix Copying file '$backup_dir/$file'\n";750 print STDERR "$prefix Copying file '$backup_dir/$file'\n";
722 $src_name = escape_path("$backup_dir/$file");751 $src_name = escape_path("$backup_dir/$file");
723 $dst_name = escape_path("$orig_iblog_dir");752 $dst_name = escape_path("$orig_iblog_dir");
724 system("$CP_CMD \"$src_name\" \"$dst_name\"")753 system("$MV_CP_CMD \"$src_name\" \"$dst_name\"")
725 and Die "Failed to copy file '$file': $!";754 and Die "Failed to copy/move file '$file': $!";
726 }755 }
727 }756 }
728 closedir(DIR);757 closedir(DIR);
@@ -1528,10 +1557,12 @@
1528 my $run = '';1557 my $run = '';
15291558
1530 # print some instructions to the user1559 # print some instructions to the user
1531 if (!$option_apply_log && !$option_copy_back) {1560 if (!$option_apply_log && !$option_copy_back && !$option_move_back) {
1532 $run = 'backup';1561 $run = 'backup';
1533 } elsif ($option_copy_back) {1562 } elsif ($option_copy_back) {
1534 $run = 'copy-back';1563 $run = 'copy-back';
1564 } elsif ($option_move_back) {
1565 $run = 'move-back';
1535 } else {1566 } else {
1536 $run = 'apply-log';1567 $run = 'apply-log';
1537 }1568 }
@@ -1541,7 +1572,7 @@
15411572
1542 # check that MySQL client program and InnoDB Hot Backup program1573 # check that MySQL client program and InnoDB Hot Backup program
1543 # are runnable via shell1574 # are runnable via shell
1544 if (!$option_copy_back) {1575 if (!$option_copy_back && !$option_move_back) {
1545 # we are making a backup or applying log to backup1576 # we are making a backup or applying log to backup
1546 if (!$option_apply_log) {1577 if (!$option_apply_log) {
1547 # we are making a backup, we need mysql server1578 # we are making a backup, we need mysql server
@@ -1589,7 +1620,7 @@
1589 #$innodb_log_group_home_dir = 1620 #$innodb_log_group_home_dir =
1590 # get_option(\%config, 'mysqld', 'innodb_log_group_home_dir');1621 # get_option(\%config, 'mysqld', 'innodb_log_group_home_dir');
15911622
1592 if (!$option_apply_log && !$option_copy_back) {1623 if (!$option_apply_log && !$option_copy_back && !$option_move_back) {
1593 # we are making a backup, create a new backup directory1624 # we are making a backup, create a new backup directory
1594 if (!$option_remote_host) {1625 if (!$option_remote_host) {
1595 $backup_dir = File::Spec->rel2abs(make_backup_dir());1626 $backup_dir = File::Spec->rel2abs(make_backup_dir());
@@ -1619,7 +1650,7 @@
1619 }1650 }
1620 }1651 }
1621 write_backup_config_file($backup_config_file);1652 write_backup_config_file($backup_config_file);
1622 } elsif ($option_copy_back) {1653 } elsif ($option_copy_back || $option_move_back) {
1623 #$backup_config_file = $backup_dir . '/backup-my.cnf';1654 #$backup_config_file = $backup_dir . '/backup-my.cnf';
1624 #read_config_file($backup_config_file, \%backup_config);1655 #read_config_file($backup_config_file, \%backup_config);
1625 } 1656 }
@@ -1715,6 +1746,7 @@
1715 'apply-log' => \$option_apply_log,1746 'apply-log' => \$option_apply_log,
1716 'redo-only' => \$option_redo_only,1747 'redo-only' => \$option_redo_only,
1717 'copy-back' => \$option_copy_back,1748 'copy-back' => \$option_copy_back,
1749 'move-back' => \$option_move_back,
1718 'include=s' => \$option_include,1750 'include=s' => \$option_include,
1719 'databases=s' => \$option_databases,1751 'databases=s' => \$option_databases,
1720 'tables-file=s', => \$option_tables_file,1752 'tables-file=s', => \$option_tables_file,
@@ -1792,7 +1824,7 @@
1792 # get options file name1824 # get options file name
1793 #$config_file = $ARGV[0];1825 #$config_file = $ARGV[0];
17941826
1795 if (!$option_apply_log && !$option_copy_back) {1827 if (!$option_apply_log && !$option_copy_back && !$option_move_back) {
1796 # we are making a backup, get backup root directory1828 # we are making a backup, get backup root directory
1797 $backup_root = $ARGV[0];1829 $backup_root = $ARGV[0];
1798 if ($option_incremental && !$option_incremental_lsn) {1830 if ($option_incremental && !$option_incremental_lsn) {
@@ -2633,7 +2665,13 @@
2633 [--export] [--redo-only] [--ibbackup=IBBACKUP-BINARY]2665 [--export] [--redo-only] [--ibbackup=IBBACKUP-BINARY]
2634 BACKUP-DIR2666 BACKUP-DIR
26352667
2636innobackupex --copy-back [--defaults-file=MY.CNF] [--defaults-group=GROUP-NAME] BACKUP-DIR2668<<<<<<< TREE
2669innobackupex --copy-back [--defaults-file=MY.CNF] [--defaults-group=GROUP-NAME] BACKUP-DIR
2670=======
2671innobackupex --copy-back [--defaults-file=MY.CNF] [--defaults-group=GROUP-NAME] BACKUP-DIR
2672
2673innobackupex --move-back [--defaults-file=MY.CNF] [--defaults-group=GROUP-NAME] BACKUP-DIR
2674>>>>>>> MERGE-SOURCE
26372675
2638=head1 DESCRIPTION2676=head1 DESCRIPTION
26392677
@@ -2663,6 +2701,10 @@
2663The MY.CNF options file defines the original location of the database.2701The MY.CNF options file defines the original location of the database.
2664The BACKUP-DIR is the path to a backup directory created by xtrabackup.2702The BACKUP-DIR is the path to a backup directory created by xtrabackup.
26652703
2704The --move-back command does just the same as --copy-back. The only difference is
2705that files are moved to data directory instead of be copied. Useful in case you
2706have not much free space at your destination server.
2707
2666On success the exit code innobackupex is 0. A non-zero exit code 2708On success the exit code innobackupex is 0. A non-zero exit code
2667indicates an error.2709indicates an error.
26682710
@@ -2691,6 +2733,10 @@
26912733
2692Copy all the files in a previously made backup from the backup directory to their original locations.2734Copy all the files in a previously made backup from the backup directory to their original locations.
26932735
2736=item --move-back
2737
2738Move all the files in a previously made backup from the backup directory to the actual datadir location.
2739
2694=item --databases=LIST2740=item --databases=LIST
26952741
2696This option specifies the list of databases that innobackupex should back up. The option accepts a string argument. The list is of the form "databasename1[.table_name1] databasename2[.table_name2] . . .". If this option is not specified, all databases containing MyISAM and InnoDB tables will be backed up. Please make sure that --databases contains all of the InnoDB databases and tables, so that all of the innodb.frm files are also backed up. In case the list is very long, this can be specified in a file, and the full path of the file can be specified instead of the list. (See option --tables-file.)2742This option specifies the list of databases that innobackupex should back up. The option accepts a string argument. The list is of the form "databasename1[.table_name1] databasename2[.table_name2] . . .". If this option is not specified, all databases containing MyISAM and InnoDB tables will be backed up. Please make sure that --databases contains all of the InnoDB databases and tables, so that all of the innodb.frm files are also backed up. In case the list is very long, this can be specified in a file, and the full path of the file can be specified instead of the list. (See option --tables-file.)
26972743
=== added file 'test/t/bug803636.sh'
--- test/t/bug803636.sh 1970-01-01 00:00:00 +0000
+++ test/t/bug803636.sh 2012-09-02 15:43:18 +0000
@@ -0,0 +1,33 @@
1. inc/common.sh
2
3start_server
4
5load_dbase_schema sakila
6load_dbase_data sakila
7
8mkdir -p $topdir/backup
9innobackupex $topdir/backup
10backup_dir=`grep "innobackupex: Backup created in directory" $OUTFILE | awk -F\' '{ print $2}'`
11vlog "Backup created in directory $backup_dir"
12
13stop_server
14# Remove datadir
15rm -r $mysql_datadir
16#init_mysql_dir
17# Restore sakila
18vlog "Applying log"
19vlog "###########"
20vlog "# PREPARE #"
21vlog "###########"
22innobackupex --apply-log $backup_dir
23vlog "Restoring MySQL datadir"
24mkdir -p $mysql_datadir
25vlog "###########"
26vlog "# RESTORE #"
27vlog "###########"
28innobackupex --move-back $backup_dir
29
30start_server
31# Check sakila
32echo ${MYSQL}
33run_cmd ${MYSQL} ${MYSQL_ARGS} -e "SELECT count(*) from actor" sakila

Subscribers

People subscribed via source and target branches