[MySQL-zrm/el6] Abort if out of space on restore

Orion Poplawski orion at fedoraproject.org
Wed Mar 19 22:31:52 UTC 2014


commit be57182d50357c0e4bdee0b37f9c1a2c4f6695fe
Author: Orion Poplawski <orion at nwra.com>
Date:   Wed Mar 19 16:23:46 2014 -0600

    Abort if out of space on restore

 MySQL-zrm-tmpwrite.patch |   33 +++++++++++++++++++++++++++++++++
 MySQL-zrm.spec           |   13 +++++++++++--
 2 files changed, 44 insertions(+), 2 deletions(-)
---
diff --git a/MySQL-zrm-tmpwrite.patch b/MySQL-zrm-tmpwrite.patch
new file mode 100644
index 0000000..7be7ef2
--- /dev/null
+++ b/MySQL-zrm-tmpwrite.patch
@@ -0,0 +1,33 @@
+diff -up MySQL-zrm-3.0/usr/bin/mysql-zrm-restore.tmpwrite MySQL-zrm-3.0/usr/bin/mysql-zrm-restore
+--- MySQL-zrm-3.0/usr/bin/mysql-zrm-restore.tmpwrite	2013-08-26 14:45:36.000000000 -0600
++++ MySQL-zrm-3.0/usr/bin/mysql-zrm-restore	2014-03-19 16:13:17.360910775 -0600
+@@ -415,7 +415,7 @@ sub extractToTmpFile()
+         $dbs =~s/\s/|/g;
+         open( MSQL, $sqlmaster ) or &printAndDie( "Could not open file $sqlmaster $!\n" );
+ 	my $tf = tmpnam();
+-        open(OF,">$tf" ) or &printAndDie( "Coupld not open tmp file $tf $!\n" );
++        open(OF,">$tf" ) or &printAndDie( "Could not open tmp file $tf $!\n" );
+         my $found = 0;
+         while(<MSQL>){
+                 if( /^-- Current Database: / ){
+@@ -425,10 +425,18 @@ sub extractToTmpFile()
+                         $found = /\`($dbs)\`/ ? 1:0;
+                 }
+                 if( $found ){
+-                        print OF $_;
++                        if ( ! print OF $_ ) {
++                                my $r = "$!";
++                                unlink( $tf );
++                                &printAndDie( "Could not write to tmp file $tf $r\n" );
++                        }
+                 }elsif( /^\/\*\!\d*\s*SET / ){
+                         # Also print if statement is "/*! SET "
+-                        print OF $_;
++                        if ( ! print OF $_ ) {
++                                my $r = "$!";
++                                unlink( $tf );
++                                &printAndDie( "Could not write to tmp file $tf $r\n" );
++                        }
+                 }
+         }
+         close( OF );
diff --git a/MySQL-zrm.spec b/MySQL-zrm.spec
index 4413db5..f3213fe 100644
--- a/MySQL-zrm.spec
+++ b/MySQL-zrm.spec
@@ -1,6 +1,6 @@
 Name:           MySQL-zrm
 Version:        3.0
-Release:        1%{?dist}
+Release:        2%{?dist}
 Summary:        MySQL backup manager
 
 Group:          Applications/System
@@ -8,7 +8,11 @@ License:        GPLv2
 URL:            http://www.zmanda.com/backup-mysql.html
 Source0:        http://www.zmanda.com/downloads/community/ZRM-MySQL/3.0/Source/MySQL-zrm-%{version}-release.tar.gz
 Patch0:         MySQL-zrm-disable-xinetd-service.patch
+# Really make --quiet quiet
 Patch1:         MySQL-zrm-2.2.0-quiet.patch
+# Abort if out of space on restore
+# https://forums.zmanda.com/showthread.php?5347-mysql-zrm-restore-does-not-check-for-running-out-of-disk-space&p=17076#post17076
+Patch2:         MySQL-zrm-tmpwrite.patch
 
 BuildRoot:      %(mktemp -ud %{_tmppath}/%{name}-%{version}-%{release}-XXXXXX)
 BuildArch:      noarch
@@ -28,8 +32,10 @@ server.
 
 %prep
 %setup -q -c
+# Cannot do backups, they get installed
 %patch0 -p1
-%patch1 -p1 -b .quiet
+%patch1 -p1
+%patch2 -p1
 
 %build
 # we should use modules from repo
@@ -90,6 +96,9 @@ rm -rf %{buildroot}
 %config(noreplace) %{_sysconfdir}/mysql-zrm/*
 
 %changelog
+* Wed Mar 19 2014 Orion Poplawski <orion at cora.nwra.com> - 3.0-2
+- Abort if out of space on restore
+
 * Tue Mar 18 2014 Orion Poplawski <orion at cora.nwra.com> - 3.0-1
 - Update to 3.0
 


More information about the scm-commits mailing list