[pve-devel] [PATCH pve-manager] vzdump: replace 'find' exclude command switches

Wolfgang Bumiller w.bumiller at proxmox.com
Thu Sep 3 15:46:24 CEST 2015


We're replacing the use of 'find' in the backup code for
various reasons, so we cannot use find-specific options
anymore. Besides, it's up to the plugin to create the
archive and there's no guarantee using 'find' even makes
sense. Even in the current code it's not being used when
hitting the rsync case anyway.

Now using simple glob patterns as that is more widely
supported.
---
 PVE/VZDump.pm | 39 ++++++++-------------------------------
 1 file changed, 8 insertions(+), 31 deletions(-)

diff --git a/PVE/VZDump.pm b/PVE/VZDump.pm
index 70fefb1..a35da14 100644
--- a/PVE/VZDump.pm
+++ b/PVE/VZDump.pm
@@ -83,7 +83,7 @@ my $confdesc = {
     },
     'exclude-path' => {
 	type => 'string', format => 'string-alist',
-	description => "exclude certain files/directories (regex).",
+	description => "exclude certain files/directories (shell globs).",
 	optional => 1,
     },
     mailto => {
@@ -347,21 +347,6 @@ sub read_vzdump_defaults {
     return $res;
 }
 
-
-sub find_add_exclude {
-    my ($self, $excltype, $value) = @_;
-
-    if (($excltype eq '-regex') || ($excltype eq '-files')) {
-	$value = "\.$value";
-    }
-
-    if ($excltype eq '-files') {
-	push @{$self->{findexcl}}, "'('", '-not', '-type', 'd', '-regex' , "'$value'", "')'", '-o';
-    } else {
-	push @{$self->{findexcl}}, "'('", $excltype , "'$value'", '-prune', "')'", '-o';
-    }
-}
-
 sub sendmail {
     my ($self, $tasklist, $totaltime, $err) = @_;
 
@@ -586,28 +571,20 @@ sub new {
     $skiplist = [] if !$skiplist;
     my $self = bless { cmdline => $cmdline, opts => $opts, skiplist => $skiplist };
 
-    #always skip '.'
-    push @{$self->{findexcl}}, "'('", '-regex' , "'^\\.\$'", "')'", '-o';
-
-    $self->find_add_exclude ('-type', 's'); # skip sockets
-
+    my $findexcl = $self->{findexcl} = [];
     if ($defaults->{'exclude-path'}) {
-	foreach my $path (@{$defaults->{'exclude-path'}}) {
-	    $self->find_add_exclude ('-regex', $path);
-	}
+	push @$findexcl, @{$defaults->{'exclude-path'}};
     }
 
     if ($opts->{'exclude-path'}) {
-	foreach my $path (@{$opts->{'exclude-path'}}) {
-	    $self->find_add_exclude ('-regex', $path);
-	}
+	push @$findexcl, @{$opts->{'exclude-path'}};
     }
 
     if ($opts->{stdexcludes}) {
-	$self->find_add_exclude ('-files', '/var/log/.+');
-	$self->find_add_exclude ('-regex', '/tmp/.+');
-	$self->find_add_exclude ('-regex', '/var/tmp/.+');
-	$self->find_add_exclude ('-regex', '/var/run/.+pid');
+	push @$findexcl, '/var/log/?*',
+	                 '/tmp/?*',
+	                 '/var/tmp/?*',
+	                 '/var/run/?*';
     }
 
     foreach my $p (@plugins) {
-- 
2.1.4




More information about the pve-devel mailing list