[PVE-User] VZDump: use --sparse on the first rsync

John O. Stevens john_o.stevens at yahoo.com
Fri Sep 16 14:29:22 CEST 2011


Hello all, and thanks for the good work so far!

I've noticed that dumps of VZ containers with sparse files
take more disk space than they should, and so here is my
proposed solution.

Rsync is called two times; this patch uses the --sparse option the first
time it's called, in order to gain better handling of sparse files, and
use the --inplace option the second time it's called.
(The first time rsync is called, normally there are no files for
--inplace to work anyway)

jos

diff -up a/PVE/VZDump/OpenVZ.pm b/PVE/VZDump/OpenVZ.pm
--- a/PVE/VZDump/OpenVZ.pm        2011-08-18 07:08:03.000000000 +0200
+++ b/PVE/VZDump/OpenVZ.pm        2011-09-16 11:14:09.000000000 +0200
@@ -148,7 +148,14 @@
 
     $rsyncopts .= " --bwlimit=$opts->{bwlimit}" if $opts->{bwlimit};
 
-    $self->cmd ("rsync $rsyncopts -aH --delete --no-whole-file --inplace '$from' '$to'");
+    if ($text eq 'first') {
+       $rsyncopts="$rsyncopts --sparse";
+    } else {
+       $rsyncopts="$rsyncopts --inplace";
+    }
+    $self->loginfo ("rsync options: $rsyncopts");
+
+    $self->cmd ("rsync $rsyncopts -aH --delete --no-whole-file '$from' '$to'");
 
     my $delay = time () - $starttime;




More information about the pve-user mailing list