[pve-devel] [PATCH manager v2 1/2] vzdump: handle backup to stdout correctly

Philip Abernethy p.abernethy at proxmox.com
Thu Sep 14 12:03:45 CEST 2017


Checks for dumpdir or tmpdir backups don't apply to stdout, so we can
skip the checks involved in those methods.
---
changes from v1:
* Added an explanation for tmpdir. I'm not sure there's much more we can do.
  If the user/admin configures the backup to save a 30G container into 16G
  memory he's bound to run into that hard limit.
* Better handling of logfile
 PVE/VZDump.pm | 10 +++++++---
 1 file changed, 7 insertions(+), 3 deletions(-)

diff --git a/PVE/VZDump.pm b/PVE/VZDump.pm
index 004672d1..c6a4b449 100644
--- a/PVE/VZDump.pm
+++ b/PVE/VZDump.pm
@@ -105,7 +105,9 @@ my $confdesc = {
     },
     tmpdir => {
 	type => 'string',
-	description => "Store temporary files to specified directory.",
+	description => "Store temporary files to specified directory. " .
+	"Takes precedence over the setting in the configuration file. " .
+	"Defaults to /var/tmp if unset.",
 	optional => 1,
     },
     dumpdir => {
@@ -574,7 +576,7 @@ sub new {
 	push @{$self->{plugins}}, $pd;
     }
 
-    if (!$opts->{dumpdir} && !$opts->{storage}) {
+    if (!$opts->{dumpdir} && !$opts->{stdout} && !$opts->{storage}) {
 	$opts->{storage} = 'local';
     }
 
@@ -592,6 +594,8 @@ sub new {
     } elsif ($opts->{dumpdir}) {
 	$errors .= "dumpdir '$opts->{dumpdir}' does not exist"
 	    if ! -d $opts->{dumpdir};
+    } elsif ($opts->{stdout}) {
+	# Nothing to do here. We don't handle what comes after stdout
     } else {
 	die "internal error"; 
     }
@@ -848,7 +852,7 @@ sub exec_backup_task {
 	$task->{storeid} = $opts->{storage};
 	$task->{tmplog} = $tmplog;
 
-	unlink $logfile;
+	unlink $logfile if defined($logfile);
 
 	debugmsg ('info',  "Starting Backup of VM $vmid ($vmtype)", $logfd, 1);
 
-- 
2.11.0





More information about the pve-devel mailing list