Merge lp:~akopytov/percona-xtrabackup/bug759701-1.7 into lp:percona-xtrabackup/2.0

Proposed by Alexey Kopytov
Status: Merged
Approved by: Stewart Smith
Approved revision: no longer in the source branch.
Merged at revision: 390
Proposed branch: lp:~akopytov/percona-xtrabackup/bug759701-1.7
Merge into: lp:percona-xtrabackup/2.0
Diff against target: 372 lines (+159/-69)
9 files modified
innobackupex (+83/-62)
test/t/bug723097.sh (+1/-1)
test/t/bug759701.sh (+69/-0)
test/t/ib_incremental.sh (+1/-1)
test/t/xb_export.sh (+1/-1)
test/t/xb_incremental.sh (+1/-1)
test/t/xb_incremental_compressed.sh (+1/-1)
test/t/xb_part_range.sh (+1/-1)
test/t/xb_partial.sh (+1/-1)
To merge this branch: bzr merge lp:~akopytov/percona-xtrabackup/bug759701-1.7
Reviewer Review Type Date Requested Status
Stewart Smith (community) Approve
Review via email: mp+86602@code.launchpad.net
To post a comment you must log in.
Revision history for this message
Alexey Kopytov (akopytov) wrote :
Revision history for this message
Stewart Smith (stewart) :
review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'innobackupex'
--- innobackupex 2011-12-17 03:23:36 +0000
+++ innobackupex 2011-12-21 18:48:30 +0000
@@ -15,6 +15,8 @@
15use FileHandle;15use FileHandle;
16use File::Basename;16use File::Basename;
17use File::Temp;17use File::Temp;
18use File::Find;
19use File::Copy;
18use English qw(-no_match_vars);20use English qw(-no_match_vars);
1921
20# version of this script22# version of this script
@@ -208,6 +210,11 @@
208my $xtrabackup_binary_file = 'xtrabackup_binary';210my $xtrabackup_binary_file = 'xtrabackup_binary';
209my %rsync_files_hash;211my %rsync_files_hash;
210212
213my $copy_dir_src;
214my $copy_dir_dst;
215my $copy_dir_exclude_regexp;
216my $copy_dir_overwrite;
217
211######################################################################218######################################################################
212# program execution begins here219# program execution begins here
213######################################################################220######################################################################
@@ -519,6 +526,58 @@
519}526}
520527
521#528#
529# Callback function for copy_dir_recursively that actually does all
530# the copying work
531#
532sub copy_file() {
533 if (/$copy_dir_exclude_regexp/) {
534 return;
535 }
536 (my $dst_path = $File::Find::name) =~ s/^$copy_dir_src/$copy_dir_dst/;
537 if (-d "$File::Find::name") {
538 # Create the directory in the destination if necessary
539 if (! -e "$dst_path") {
540 print STDERR "$prefix Creating directory '$dst_path'\n";
541 mkdir "$dst_path" or Die "mkdir failed: $!";
542 } elsif (! -d "$dst_path") {
543 Die "$dst_path exists, but is not a directory";
544 }
545 } else {
546 # Don't overwrite files unless $copy_dir_overwrite is 1
547 if (!$copy_dir_overwrite && -e "$copy_dir_dst/$_") {
548 Die "Failed to copy file $File::Find::name: " .
549 "file $copy_dir_dst/$_ exists";
550 }
551
552 print STDERR "$prefix Copying file '$copy_dir_dst/$_'\n";
553 copy($File::Find::name, $dst_path) or Die "copy failed: $!";
554 }
555}
556
557#
558# copy_dir_recursively subroutine does a recursive copy of a specified
559# directory excluding files matching a specifies regexp. If $overwrite
560# is 1, it overwrites the existing files.
561#
562# SYNOPSIS
563#
564# copy_dir_recursively($src_dir, $dst_dir, $exclude_regexp,
565# $overwrite);
566#
567# TODO
568#
569# use rsync when --rsync is specified
570#
571sub copy_dir_recursively {
572 $copy_dir_src = shift;
573 $copy_dir_dst = shift;
574 $copy_dir_exclude_regexp = shift;
575 $copy_dir_overwrite = shift;
576
577 find(\&copy_file, $copy_dir_src);
578}
579
580#
522# copy_back subroutine copies data and index files from backup directory 581# copy_back subroutine copies data and index files from backup directory
523# back to their original locations.582# back to their original locations.
524#583#
@@ -530,10 +589,11 @@
530 get_option(\%config, 'mysqld', 'innodb_data_file_path');589 get_option(\%config, 'mysqld', 'innodb_data_file_path');
531 my $orig_iblog_dir =590 my $orig_iblog_dir =
532 get_option(\%config, 'mysqld', 'innodb_log_group_home_dir');591 get_option(\%config, 'mysqld', 'innodb_log_group_home_dir');
592 my $iblog_files = 'ib_logfile.*';
533 my $excluded_files = 593 my $excluded_files =
534 '^(\.\.?|backup-my\.cnf|xtrabackup_logfile|mysql-std(err|out)|.*\.ibz)$';594 '\.\.?|backup-my\.cnf|xtrabackup_logfile|' .
535 my @ibdata_files;595 'xtrabackup_binary|xtrabackup_binlog_info|xtrabackup_checkpoints' .
536 my $iblog_files = '^ib_logfile.*$';596 $iblog_files;
537 my $compressed_data_file = '.*\.ibz$';597 my $compressed_data_file = '.*\.ibz$';
538 my $file;598 my $file;
539 my $backup_innodb_data_file_path;599 my $backup_innodb_data_file_path;
@@ -573,59 +633,20 @@
573 Die "Backup data file '$backup_dir/$filename' does not exist.";633 Die "Backup data file '$backup_dir/$filename' does not exist.";
574 }634 }
575 }635 }
576636
577 if (!is_in_array($filename, \@ibdata_files)) {637 $excluded_files .= "|\Q$filename\E";
578 push(@ibdata_files, $filename);
579 }
580 }638 }
581639
582 # copy files from backup dir to their original locations640 # copy files from backup dir to their original locations
583641
584 # copy files to original data directory642 # copy files to original data directory
585 opendir(DIR, $backup_dir) 643 my $excluded_regexp = '^(' . $excluded_files . ')$';
586 || Die "Can't open directory '$backup_dir': $!\n";644 print STDERR "$prefix Starting to copy files in '$backup_dir'\n";
587 print STDERR "$prefix Starting to copy MyISAM tables, indexes,\n";
588 print STDERR "$prefix .MRG, .TRG, .TRN, .ARM, .ARZ, .CSM, .CSV, .opt, and .frm files\n";
589 print STDERR "$prefix in '$backup_dir'\n";
590 print STDERR "$prefix back to original data directory '$orig_datadir'\n";645 print STDERR "$prefix back to original data directory '$orig_datadir'\n";
591 while (defined($file = readdir(DIR))) {646 copy_dir_recursively($backup_dir, $orig_datadir, $excluded_regexp, 0);
592 if ($file =~ /$excluded_files/) { next; }
593 if (is_in_array($file, \@ibdata_files)) { next; }
594 if ($file =~ /$iblog_files/) { next; }
595 if (-d "$backup_dir/$file") {
596 my $subdir = "$backup_dir/$file";
597 my $file2;
598
599 print STDERR "$prefix Copying directory '$subdir'\n";
600 if (! -x "\"".escape_path("$orig_datadir/$file")."\"") {
601 system("mkdir \"".escape_path("$orig_datadir/$file")."\"")
602 and Die "Failed to create directory "
603 . "'$orig_datadir/$file' : $!";
604 }
605 opendir(SUBDIR, "$subdir")
606 || Die "Can't open directory '$subdir': $!\n";
607 while (defined($file2 = readdir(SUBDIR))) {
608 if (-d "$subdir/$file2") { next; }
609 if ($file2 =~ /$compressed_data_file/) { next; }
610 $src_name = escape_path("$subdir/$file2");
611 $dst_name = escape_path("$orig_datadir/$file");
612 system("$CP_CMD \"$src_name\" \"$dst_name\"")
613 and Die "Failed to copy file '$file': $!";
614 }
615 closedir(SUBDIR);
616 } else {
617 print STDERR "$prefix Copying file " .
618 "'$backup_dir/$file'\n";
619 $src_name = escape_path("$backup_dir/$file");
620 $dst_name = escape_path("$orig_datadir");
621 system("$CP_CMD \"$src_name\" \"$dst_name\"")
622 and Die "Failed to copy file '$file': $!";
623 }
624 }
625 closedir(DIR);
626647
627 # copy InnoDB data files to original InnoDB data directory648 # copy InnoDB data files to original InnoDB data directory
628 print STDERR "\n$prefix Starting to copy InnoDB tables and indexes\n";649 print STDERR "\n$prefix Starting to copy InnoDB system tablespace\n";
629 print STDERR "$prefix in '$backup_dir'\n";650 print STDERR "$prefix in '$backup_dir'\n";
630 print STDERR "$prefix back to original InnoDB data directory '$orig_ibdata_dir'\n";651 print STDERR "$prefix back to original InnoDB data directory '$orig_ibdata_dir'\n";
631 foreach my $a (split(/;/, $orig_innodb_data_file_path)) {652 foreach my $a (split(/;/, $orig_innodb_data_file_path)) {
@@ -646,7 +667,7 @@
646 print STDERR "$prefix in '$backup_dir'\n";667 print STDERR "$prefix in '$backup_dir'\n";
647 print STDERR "$prefix back to original InnoDB log directory '$orig_iblog_dir'\n";668 print STDERR "$prefix back to original InnoDB log directory '$orig_iblog_dir'\n";
648 while (defined($file = readdir(DIR))) {669 while (defined($file = readdir(DIR))) {
649 if ($file =~ /$iblog_files/ && -f "$backup_dir/$file") {670 if ($file =~ /'^' . $iblog_files . '$'/ && -f "$backup_dir/$file") {
650 print STDERR "$prefix Copying file '$backup_dir/$file'\n";671 print STDERR "$prefix Copying file '$backup_dir/$file'\n";
651 $src_name = escape_path("$backup_dir/$file");672 $src_name = escape_path("$backup_dir/$file");
652 $dst_name = escape_path("$orig_iblog_dir");673 $dst_name = escape_path("$orig_iblog_dir");
@@ -714,20 +735,20 @@
714 }735 }
715 }736 }
716737
717 # If we were applying an incremental change set, we need to make sure the xtrabackup_slave_info is still correct738 # If we were applying an incremental change set, we need to make
739 # sure non-InnoDB files and xtrabackup_* metainfo files are copied
740 # to the full backup directory.
718 if ( $option_incremental_dir ) {741 if ( $option_incremental_dir ) {
719742 print STDERR "$prefix Starting to copy non-InnoDB files in '$option_incremental_dir'\n";
720 # If the latest backup has this file, then update the target dir with the new file743 print STDERR "$prefix to the full backup directory '$backup_dir'\n";
721 if ( -e "$option_incremental_dir/xtrabackup_slave_info" ) {744 copy_dir_recursively($option_incremental_dir, $backup_dir,
722 print STDERR "\n$now $prefix Updating xtrabackup_slave_info with new slave position info...";745 '^(\.\.?|backup-my\.cnf|xtrabackup_logfile|' .
723 $cmdline = "cp $option_incremental_dir/xtrabackup_slave_info $backup_dir/xtrabackup_slave_info";746 'xtrabackup_binary|xtrabackup_checkpoints|' .
724 $rcode = system("$cmdline");747 '.*\.delta|.*\.meta|ib_logfile.*)$', 1);
725 if ($rcode) {748 # If the latest backup has no file, we need to remove the old
726 # failure749 # xtrabackup_slave_info file, because it is out of date
727 Die "\n$prefix Failed to update xtrabackup_slave_info in $backup_dir";750 # TODO: this will not be needed when bug #856400 is fixed.
728 }751 if ( -e "$backup_dir/xtrabackup_slave_info" ) {
729 # If the latest backup has no file, we need to remove the old xtrabackup_slave_info file, because it is out of date
730 } elsif ( -e "$backup_dir/xtrabackup_slave_info" ) {
731 print STDERR "\n$now $prefix No updated xtrabackup_slave_info found in incremental dir, removing stale xtrabackup_slave_info file from target dir.";752 print STDERR "\n$now $prefix No updated xtrabackup_slave_info found in incremental dir, removing stale xtrabackup_slave_info file from target dir.";
732 $cmdline = "rm $backup_dir/xtrabackup_slave_info";753 $cmdline = "rm $backup_dir/xtrabackup_slave_info";
733 $rcode = system("$cmdline");754 $rcode = system("$cmdline");
734755
=== modified file 'test/t/bug723097.sh'
--- test/t/bug723097.sh 2011-09-14 17:41:10 +0000
+++ test/t/bug723097.sh 2011-12-21 18:48:30 +0000
@@ -27,7 +27,7 @@
27checksum_b=`checksum_table test messages`27checksum_b=`checksum_table test messages`
28vlog "Checksum after is $checksum_b"28vlog "Checksum after is $checksum_b"
2929
30if [ $checksum_a -eq $checksum_b ]30if [ "$checksum_a" -eq "$checksum_b" ]
31then31then
32 vlog "Checksums are Ok"32 vlog "Checksums are Ok"
33else33else
3434
=== added file 'test/t/bug759701.sh'
--- test/t/bug759701.sh 1970-01-01 00:00:00 +0000
+++ test/t/bug759701.sh 2011-12-21 18:48:30 +0000
@@ -0,0 +1,69 @@
1##########################################################################
2# Bug #759701: innobackupex does not copy non-InnoDB files when applying #
3# incremental backups #
4##########################################################################
5. inc/common.sh
6
7init
8run_mysqld --innodb_file_per_table
9load_sakila
10
11# Full backup
12# backup root directory
13vlog "Starting backup"
14
15full_backup_dir=$topdir/full_backup
16innobackupex --no-timestamp $full_backup_dir
17
18# Changing data
19
20run_cmd $MYSQL $MYSQL_ARGS -e "CREATE DATABASE newdb"
21run_cmd $MYSQL $MYSQL_ARGS -e \
22 "CREATE TABLE actor_copy ENGINE=MyISAM SELECT * FROM sakila.actor" newdb
23
24# Saving the checksum of original table
25checksum_a=`checksum_table newdb actor_copy`
26test -n "$checksum_a" || die "Failed to checksum table actor_copy"
27
28vlog "Making incremental backup"
29
30# Incremental backup
31inc_backup_dir=$topdir/incremental_backup
32innobackupex --incremental --no-timestamp \
33 --incremental-basedir=$full_backup_dir $inc_backup_dir
34vlog "Incremental backup created in directory $inc_backup_dir"
35
36vlog "Preparing backup"
37innobackupex --apply-log --redo-only $full_backup_dir
38vlog "Log applied to full backup"
39
40innobackupex --apply-log --redo-only --incremental-dir=$inc_backup_dir \
41 $full_backup_dir
42vlog "Delta applied to full backup"
43
44innobackupex --apply-log $full_backup_dir
45vlog "Data prepared for restore"
46
47# Destroying mysql data
48stop_mysqld
49rm -rf $mysql_datadir/*
50vlog "Data destroyed"
51
52# Restore backup
53vlog "Copying files to their original locations"
54innobackupex --copy-back $full_backup_dir
55vlog "Data restored"
56
57run_mysqld --innodb_file_per_table
58
59vlog "Checking checksums"
60checksum_b=`checksum_table newdb actor_copy`
61
62vlog "Old checksum: $checksum_a"
63vlog "New checksum: $checksum_b"
64
65if [ "$checksum_a" != "$checksum_b" ]
66then
67 vlog "Checksums do not match"
68 exit -1
69fi
070
=== modified file 'test/t/ib_incremental.sh'
--- test/t/ib_incremental.sh 2011-09-14 17:41:10 +0000
+++ test/t/ib_incremental.sh 2011-12-21 18:48:30 +0000
@@ -89,7 +89,7 @@
89vlog "Checking checksums"89vlog "Checking checksums"
90checksum_b=`checksum_table incremental_sample test`90checksum_b=`checksum_table incremental_sample test`
9191
92if [ $checksum_a -ne $checksum_b ]92if [ "$checksum_a" != "$checksum_b" ]
93then 93then
94 vlog "Checksums are not equal"94 vlog "Checksums are not equal"
95 exit -195 exit -1
9696
=== modified file 'test/t/xb_export.sh'
--- test/t/xb_export.sh 2011-09-14 17:41:10 +0000
+++ test/t/xb_export.sh 2011-12-21 18:48:30 +0000
@@ -123,7 +123,7 @@
123checksum_3=`checksum_table incremental_sample test`123checksum_3=`checksum_table incremental_sample test`
124vlog "checksum_3 is $checksum_3"124vlog "checksum_3 is $checksum_3"
125125
126if [ "$checksum_3" != $checksum_2 ]126if [ "$checksum_3" != "$checksum_2" ]
127then127then
128 vlog "Checksums are not equal"128 vlog "Checksums are not equal"
129 exit -1129 exit -1
130130
=== modified file 'test/t/xb_incremental.sh'
--- test/t/xb_incremental.sh 2011-09-14 17:41:10 +0000
+++ test/t/xb_incremental.sh 2011-12-21 18:48:30 +0000
@@ -85,7 +85,7 @@
85vlog "Checking checksums"85vlog "Checking checksums"
86checksum_b=`checksum_table incremental_sample test`86checksum_b=`checksum_table incremental_sample test`
8787
88if [ $checksum_a -ne $checksum_b ]88if [ "$checksum_a" != "$checksum_b" ]
89then 89then
90 vlog "Checksums are not equal"90 vlog "Checksums are not equal"
91 exit -191 exit -1
9292
=== modified file 'test/t/xb_incremental_compressed.sh'
--- test/t/xb_incremental_compressed.sh 2011-09-14 17:41:10 +0000
+++ test/t/xb_incremental_compressed.sh 2011-12-21 18:48:30 +0000
@@ -149,7 +149,7 @@
149 vlog "Cheking checksums"149 vlog "Cheking checksums"
150 checksum_b=`checksum_table incremental_sample test`150 checksum_b=`checksum_table incremental_sample test`
151151
152 if [ $checksum_a -ne $checksum_b ]152 if [ "$checksum_a" != "$checksum_b" ]
153 then 153 then
154 vlog "Checksums are not equal"154 vlog "Checksums are not equal"
155 exit -1155 exit -1
156156
=== modified file 'test/t/xb_part_range.sh'
--- test/t/xb_part_range.sh 2011-09-14 17:41:10 +0000
+++ test/t/xb_part_range.sh 2011-12-21 18:48:30 +0000
@@ -104,7 +104,7 @@
104vlog "Cheking checksums"104vlog "Cheking checksums"
105checksum_b=`checksum_table test test`105checksum_b=`checksum_table test test`
106106
107if [ $checksum_a -ne $checksum_b ]107if [ "$checksum_a" != "$checksum_b" ]
108then 108then
109 vlog "Checksums are not equal"109 vlog "Checksums are not equal"
110 exit -1110 exit -1
111111
=== modified file 'test/t/xb_partial.sh'
--- test/t/xb_partial.sh 2011-09-14 17:41:10 +0000
+++ test/t/xb_partial.sh 2011-12-21 18:48:30 +0000
@@ -44,7 +44,7 @@
44vlog "Checking checksums"44vlog "Checking checksums"
45checksum_b=`checksum_table incremental_sample test`45checksum_b=`checksum_table incremental_sample test`
4646
47if [ $checksum_a -ne $checksum_b ]47if [ "$checksum_a" != "$checksum_b" ]
48then 48then
49 vlog "Checksums are not equal"49 vlog "Checksums are not equal"
50 exit -150 exit -1

Subscribers

People subscribed via source and target branches