Skip to content
Snippets Groups Projects
Commit c10160a9 authored by root's avatar root
Browse files

backup: Fixes in the restore script

parent 5853ea30
No related branches found
No related tags found
No related merge requests found
......@@ -7,12 +7,6 @@ use File::Spec::Functions ( "catfile", "catdir", "file_name_is_absolute", "split
use Scalar::Util ( "tainted" );
$ENV{PATH} = "/usr/local/bin:/usr/bin:/bin";
my $thrs = 1;
if ( `nproc` =~ /^([0-9])$/ ) {
$thrs = int( $1 / 4 );
$thrs = 1 if $thrs <= 0;
$thrs = 8 if $thrs > 8;
}
sub usage {
my ( $stream ) = @_;
......@@ -43,7 +37,8 @@ if ( (shift @ARGV) =~ /([0-9]+-[0-9]+-[0-9]+)/ ) {
}
my @paths = ();
for my $p ( @ARGV ) {
if ( $p =~ m|^(/.*)$| ) {
# strip the leading / to match paths in the tar
if ( $p =~ m|^/(.*)$| ) {
push( @paths, $1 );
} else {
print STDERR "Expected absolute path but got $p\n";
......@@ -84,8 +79,8 @@ for my $backup ( @backups ) {
my @to_restore = ( $full, @weekly, @daily );
for my $backup ( @to_restore ) {
print $backup . ": " . tainted( $backup ) . "\n";
system( "tar", "--extract", "--auto-compress", "--incremental", "--xattrs",
"--acls", "-vv", "-T$thrs", "-f$backup", "--", @paths ) == 0
or die "extract of $backup failed $?";
print "$backup\n";
my @args = ( "tar", "--extract", "--auto-compress", "--incremental", "--xattrs",
"--acls", "-vv", "-f$backup", "--", @paths );
system( @args ) == 0 or die "extract of $backup failed with $?, @args\n";
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment