Merge lp:~akopytov/percona-xtrabackup/bug924026-2.0 into lp:percona-xtrabackup/2.0

Proposed by Alexey Kopytov
Status: Merged
Merged at revision: 381
Proposed branch: lp:~akopytov/percona-xtrabackup/bug924026-2.0
Merge into: lp:percona-xtrabackup/2.0
Diff against target: 49 lines (+30/-2)
1 file modified
innobackupex (+30/-2)
To merge this branch: bzr merge lp:~akopytov/percona-xtrabackup/bug924026-2.0
Reviewer Review Type Date Requested Status
Percona core Pending
Review via email: mp+91625@code.launchpad.net
To post a comment you must log in.
Revision history for this message
Alexey Kopytov (akopytov) wrote :

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'innobackupex'
2--- innobackupex 2012-02-02 20:45:13 +0000
3+++ innobackupex 2012-02-06 10:12:18 +0000
4@@ -493,6 +493,33 @@
5
6
7 #
8+# copy_if_exists subroutin attempt to copy a file from $src to $dst
9+# If the copy fails due to the file not existing, the error is ignored
10+# Parameters:
11+# $src The source file to copy
12+# $dst The destination to copy to
13+# Return value:
14+# 1 if copy was successful, or unsuccessful but the source file didn't exist
15+# 0 otherwise
16+#
17+sub copy_if_exists {
18+ my $src = shift;
19+ my $dst = shift;
20+
21+ # Copy the file
22+ if( system("$CP_CMD \"$src\" \"$dst\"") != 0 ) {
23+ # if the copy failed, check if the file exists
24+ if( -e "$src" ) {
25+ # if the file exists, we had a real error
26+ return 0;
27+ }
28+ }
29+ # Success otherwise
30+ return 1;
31+}
32+
33+
34+#
35 # is_in_array subroutine checks if the given string is in the array.
36 # Parameters:
37 # str a string
38@@ -2046,8 +2073,9 @@
39 } elsif (!$option_remote_host && !$option_stream) {
40 $src_name = escape_path("$source_dir/$database/$file");
41 $dst_name = escape_path("$backup_dir/$database");
42- system("$CP_CMD \"$src_name\" \"$dst_name\"")
43- and Die "Failed to copy file '$file': $!";
44+ # Copy the file - If we get an error and the file actually exists, die with error msg
45+ copy_if_exists("$src_name", "$dst_name")
46+ or Die "Failed to copy file '$file': $!";
47 } elsif ($option_remote_host) {
48 # Queue up files for one single scp per database.
49 push(@scp_files, "'$file'");

Subscribers

People subscribed via source and target branches