[pve-devel] r5330 - vzdump/trunk

svn-commits at proxmox.com svn-commits at proxmox.com
Mon Dec 6 06:59:17 CET 2010


Author: dietmar
Date: 2010-12-06 06:59:17 +0100 (Mon, 06 Dec 2010)
New Revision: 5330

Modified:
   vzdump/trunk/ChangeLog
   vzdump/trunk/vzdump
Log:


Modified: vzdump/trunk/ChangeLog
===================================================================
--- vzdump/trunk/ChangeLog	2010-12-03 13:12:23 UTC (rev 5329)
+++ vzdump/trunk/ChangeLog	2010-12-06 05:59:17 UTC (rev 5330)
@@ -1,3 +1,9 @@
+2010-12-06  Proxmox Support Team  <support at proxmox.com>
+
+	* vzdump (print_usage): add new --stdout option (make sure that
+	nobody writes STDOUT by redirectind STDOUT to STDERR (saving old
+	STDOUT for later use)
+
 2010-11-08  Proxmox Support Team  <support at proxmox.com>
 
 	* vzrestore (restore_openvz): correctly replace

Modified: vzdump/trunk/vzdump
===================================================================
--- vzdump/trunk/vzdump	2010-12-03 13:12:23 UTC (rev 5329)
+++ vzdump/trunk/vzdump	2010-12-06 05:59:17 UTC (rev 5330)
@@ -64,6 +64,7 @@
 		'maxfiles=i',
 		'script=s',
 		'storage=s',
+                'stdout',
 		);
 
 sub print_usage {
@@ -79,6 +80,7 @@
     print STDERR "\t--dumpdir DIR\t\tstore resulting files in DIR\n";
     print STDERR "\t--maxfiles N\t\tmaximal number of backup files per VM\n";
     print STDERR "\t--script FILENAME\texecute hook script\n"; 
+    print STDERR "\t--stdout write to stdout, not to a file\n"; 
     print STDERR "\t--storage STORAGE_ID\tstore resulting files to STORAGE_ID (PVE only)\n";
     print STDERR "\t--tmpdir DIR\t\tstore temporary files in DIR\n\n";
 
@@ -128,9 +130,18 @@
     exit (-1);
 }
 
-if ($opts->{quiet}) {
-    open STDOUT, '>/dev/null';
-    open STDERR, '>/dev/null';
+open STDOUT, '>/dev/null' if $opts->{quiet} && !$opts->{stdout};
+open STDERR, '>/dev/null' if ($opts->{quiet};
+
+if ($opts->{stdout}) {
+
+    open my $saved_stdout, ">&STDOUT"
+	|| die "can't dup STDOUT: $!\n";
+
+    open STDOUT, '>&STDERR' ||
+	die "unable to redirect STDOUT: $!\n";
+
+    $opts->{stdout} = $saved_stdout;
 }
 
 $opts->{vmids} = PVE::VZDump::check_vmids (@ARGV) if !$opts->{all};
@@ -184,6 +195,9 @@
 
 --dumpdir DIR           store resulting files in DIR
 
+--stdout                write to stdout, not to a file. You can only
+                        backup a single VM when using this mode. 
+
 --maxfiles N            maximal number of backup files per VM.
 
 --tmpdir DIR            store temporary files in DIR. --suspend and --stop



More information about the pve-devel mailing list