Merge lp:~percona-dev/percona-xtrabackup/exit-code into lp:percona-xtrabackup/2.0

Proposed by Daniel Nichter
Status: Merged
Approved by: Vadim Tkachenko
Approved revision: not available
Merged at revision: not available
Proposed branch: lp:~percona-dev/percona-xtrabackup/exit-code
Merge into: lp:percona-xtrabackup/2.0
Diff against target: 77 lines (+20/-9)
1 file modified
innobackupex-1.5.1 (+20/-9)
To merge this branch: bzr merge lp:~percona-dev/percona-xtrabackup/exit-code
Reviewer Review Type Date Requested Status
Vadim Tkachenko Approve
Review via email: mp+20407@code.launchpad.net
To post a comment you must log in.
Revision history for this message
Daniel Nichter (daniel-nichter) wrote :

Gets ibbackup/xtrabackup exit code and exits with the same code instead of always zero. Note that if xtrabackup dies or exits too soon, innobackupex dies with it, reporting "ibbackup child process has died".

Revision history for this message
Vadim Tkachenko (vadim-tk) :
review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'innobackupex-1.5.1'
2--- innobackupex-1.5.1 2010-02-24 18:39:36 +0000
3+++ innobackupex-1.5.1 2010-03-01 22:11:15 +0000
4@@ -14,7 +14,7 @@
5 use POSIX "tmpnam";
6 use FileHandle;
7 use File::Basename;
8-
9+use English qw(-no_match_vars);
10
11 # version of this script
12 my $innobackup_version = '1.5.1-xtrabackup';
13@@ -200,6 +200,8 @@
14 # initialize global variables and perform some checks
15 init();
16
17+my $ibbackup_exit_code = 0;
18+
19 if ($option_copy_back) {
20 # copy files from backup directory back to their original locations
21 copy_back();
22@@ -208,18 +210,24 @@
23 apply_log();
24 } else {
25 # make a backup of InnoDB and MyISAM tables, indexes and .frm files.
26- backup();
27+ $ibbackup_exit_code = backup();
28 }
29
30-# program has completed successfully
31 $now = current_time();
32-print STDERR "$now $prefix completed OK!\n";
33
34 if ($option_stream eq 'tar') {
35- print STDERR "$prefix You must use -i (--ignore-zeros) option for extraction of the tar stream.\n";
36-}
37-
38-exit 0;
39+ print STDERR "$prefix You must use -i (--ignore-zeros) option for extraction of the tar stream.\n";
40+}
41+
42+if ( $ibbackup_exit_code == 0 ) {
43+ # program has completed successfully
44+ print STDERR "$now $prefix completed OK!\n";
45+}
46+else {
47+ print STDERR "$now $prefix $option_ibbackup_binary failed! (exit code $ibbackup_exit_code) The backup may not be complete.\n";
48+}
49+
50+exit $ibbackup_exit_code;
51
52 ######################################################################
53 # end of program execution
54@@ -506,7 +514,7 @@
55 }
56
57 # resume ibbackup and wait till it has finished
58- resume_ibbackup();
59+ my $ibbackup_exit_code = resume_ibbackup();
60
61 if (!$option_incremental) {
62 # release read locks on all tables
63@@ -541,6 +549,8 @@
64 if ($mysql_slave_position && $option_slave_info) {
65 print STDERR "$prefix MySQL slave binlog position: $mysql_slave_position\n";
66 }
67+
68+ return $ibbackup_exit_code;
69 }
70
71
72@@ -824,6 +834,7 @@
73 # wait for ibbackup to finish
74 waitpid($ibbackup_pid, 0);
75 $ibbackup_pid = '';
76+ return $CHILD_ERROR >> 8;
77 }
78
79

Subscribers

People subscribed via source and target branches