Commit 422ad8a4 authored by Nigel Kukard's avatar Nigel Kukard
Browse files

Added --tar-ignore-failed-read option

Improved exclusion of directories
parent 60cfdb32
......@@ -43,7 +43,7 @@ use MIME::Base64;
my $VERSION = "0.0.x";
# System dirs we don't care about
my @defaultSystemExcl = ("/dev","/run","/proc","/sys","/tmp","/var/tmp");
my @defaultSystemExcl = ("/dev","/run","/proc","/sys","/tmp","/var/tmp","/misc","/media","/mnt");
# These should be backed up separately
my @defaultDataExcl = (
"/var/lib/mysql","/var/lib/pgsql",
......@@ -111,6 +111,8 @@ GetOptions(\%optctl,
"system-base=s@",
"system-dir=s@",
"tar-ignore-failed-read=s@",
"exclude-data",
"data-dir=s@",
......@@ -197,6 +199,12 @@ if (!defined($config{'system-dir'})) {
$config{'system-dir'} = toArray($config{'system-dir'});
}
if (!defined($config{'tar-ignore-failed-read'})) {
$config{'tar-ignore-failed-read'} = [];
} else {
$config{'tar-ignore-failed-read'} = toArray($config{'tar-ignore-failed-read'});
}
if (!defined($config{'data-dir'})) {
$config{'data-dir'} = [];
} else {
......@@ -284,6 +292,10 @@ if (defined($optctl{'system-dir'})) {
push(@{$config{'system-dir'}},@{$optctl{'system-dir'}});
}
if (defined($optctl{'tar-ignore-failed-read'})) {
push(@{$config{'tar-ignore-failed-read'}},@{$optctl{'tar-ignore-failed-read'}});
}
if (defined($optctl{'data-dir'})) {
push(@{$config{'data-dir'}},@{$optctl{'data-dir'}});
}
......@@ -534,6 +546,11 @@ sub backup
$srcDirList{$path}->{$item}->{'mode'} = $mode;
return;
# Check if we're a socket
} elsif (S_ISSOCK($mode)) {
# Blatently ignore...
return;
}
# Initialize file state
......@@ -761,6 +778,18 @@ sub backup
}
close(MANIFEST);
# tar specifics...
if ($newPathAttribs{$path}->{'format'} eq "tar") {
# Exclude paths for tar-ignore-failed-read
foreach my $item (@{$config{'tar-ignore-failed-read'}}) {
# Check...
if ("/$path" eq $item) {
printLog(LOG_NOTICE,"B: Path '[$source]/$path' ignore-failed-read passed to tar\n");
push(@tarArgs,"--ignore-failed-read",$path);
}
}
}
# Change dir and start backup
system(
"tar",
......@@ -1246,6 +1275,10 @@ Usage: $0 [args] <src> <dst>
--system-base=path Add a system base. This defaults to /
and this option will override that.
--tar-ignore-failed-read=path This is passed to tar only. It will
not cause errors of files that cannot
be read for the path matched.
Restore Options:
--restore|-r Restore src to dst.
--tar-keep-newer Do not overwrite newer files.
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment