]> git.proxmox.com Git - pve-container.git/commitdiff
vzdump: lxc find/mp update 2: archive
authorWolfgang Bumiller <w.bumiller@proxmox.com>
Tue, 15 Sep 2015 08:07:21 +0000 (10:07 +0200)
committerDietmar Maurer <dietmar@proxmox.com>
Wed, 16 Sep 2015 07:55:53 +0000 (09:55 +0200)
To void at least some weird quoting issues, and since tar
has a --one-file-system option, always skips sockets and
also supports exclusion by pattern we now simply use tar
directly instead of passing files listed by 'find'.

src/PVE/VZDump/LXC.pm

index 047f998fc238dd051f8366643253d79828047aa0..83e2ab719ad5176961474f1ff327b402fa9af294 100644 (file)
@@ -263,16 +263,11 @@ sub archive {
        $task->{snapdir} = $rootdir;
     }
 
-    my $findexcl = $self->{vzdump}->{findexcl};
-    push @$findexcl, "'('", '-path', "./etc/vzdump", "-prune", "')'", '-o';
-
-    my $findargs = join (' ', @$findexcl) . ' -print0';
     my $opts = $self->{vzdump}->{opts};
-
     my $snapdir = $task->{snapdir};
     my $tmpdir = $task->{tmpdir};
 
-    my $taropts = "--totals --sparse --numeric-owner --no-recursion --xattrs --one-file-system";
+    my $taropts = "--totals --sparse --numeric-owner --xattrs --one-file-system";
 
     # note: --remove-files does not work because we do not 
     # backup all files (filters). tar complains:
@@ -282,25 +277,31 @@ sub archive {
     #       $taropts .= " --remove-files"; # try to save space
     #}
 
-    my $cmd = "(";
-
-    $cmd .= "cd $snapdir;find . $findargs|sed 's/\\\\/\\\\\\\\/g'|";
-    $cmd .= "tar cpf - $taropts ";
+    my $cmd = "tar cpf - $taropts ";
     # The directory parameter can give a alternative directory as source.
     # the second parameter gives the structure in the tar.
     $cmd .= "--directory=$tmpdir ./etc/vzdump/pct.conf ";
-    $cmd .= "--directory=$snapdir --null -T -";
+    $cmd .= "--directory=$snapdir";
+
+    foreach my $exclude (@{$self->{vzdump}->{findexcl}}) {
+       $cmd .= " --exclude=.$exclude";
+    }
+
+    # add every enabled mountpoint (since we use --one-file-system)
+    my $disks = $task->{disks};
+    # mp already starts with a / so we only need to add the dot
+    foreach my $disk (@$disks) {
+       $cmd .= " .$disk->{mp}";
+    }
 
     my $bwl = $opts->{bwlimit}*1024; # bandwidth limit for cstream
     $cmd .= "|cstream -t $bwl" if $opts->{bwlimit};
     $cmd .= "|$comp" if $comp;
 
-    $cmd .= ")";
-
     if ($opts->{stdout}) {
        $self->cmd ($cmd, output => ">&" . fileno($opts->{stdout}));
     } else {
-       $self->cmd ("$cmd >$filename");
+       $self->cmd ("$cmd >" . PVE::Tools::shellquote($filename));
     }
 }