# state of share in that particular moment! (it's fast, though)
my $cleanup_before_increment = 0;
+# this option will probably create wrong increments, but it's here for
+# testing and comparison. In short, don't use it!
+my $restore_via_temp_dir = 1;
+
# connect to BackupPC_server
-die("BackupPC::Lib->new failed\n") if ( !(my $bpc = BackupPC::Lib->new) );
+my $bpc = BackupPC::Lib->new(undef, undef, 1) || die;
my %Conf = $bpc->Conf();
$bpc->ChildInit();
print "# using $inc_tmp_dir for increment scratch space";
cleanup_inc_temp_dir() if (! $cleanup_before_increment);
+my $restore_path = "$Conf{InstallDir}/$Conf{GzipTempDir}/${host}-restore.tar.gz";
+
# create restore host configuration
my $conf_restore = <<'_END_OF_CONF_';
#$Conf{TarIncrArgs} = '';
#$Conf{ClientTimeout} = 600;
+
+_END_OF_CONF_
+
+$conf_restore .= <<'_END_OF_CONF_' if (! $restore_via_temp_dir);
+
#$Conf{TarClientCmd} = '';
#$Conf{TarFullArgs} = 'gzip -cdv __restore_path__';
-$Conf{TarClientCmd} = '$tarPath -c -v -f - -C __inc_tmp_dir__ --totals';
+# force BackupPC_tarExtract to produce output of tar -c -v -f - --totals
+# so that we can just pipe tar into it!
+$Conf{tarExtractEmulateTotals} = 1;
+$Conf{TarClientCmd} = 'zcat __restore_path__';
+
+_END_OF_CONF_
+
+$conf_restore .= <<'_END_OF_CONF_' if ($restore_via_temp_dir);
-1;
+$Conf{TarClientCmd} = '$tarPath -c -v -f - -C __inc_tmp_dir__ --totals';
_END_OF_CONF_
$conf_restore =~ s/__share__/$share/gs;
$conf_restore =~ s/__inc_tmp_dir__/$inc_tmp_dir/gs;
+$conf_restore =~ s/__restore_path__/$restore_path/gs;
+
+$conf_restore .= "\n1;\n";
my $config_file = "$bpc->{TopDir}/conf/${host}.pl";
return;
}
- print "restoring $path\n";
+ if ($restore_via_temp_dir) {
+
+ print "restoring $path (extracting to create increment)\n";
+
+ cleanup_inc_temp_dir() if ($cleanup_before_increment);
+
+ my $cmd = "cd $inc_tmp_dir && tar xfz $path";
+ system($cmd) == 0 or die "can't execute: $cmd -- $?\n";
+
+ } else {
+
+ print "using $path to create increment\n";
- cleanup_inc_temp_dir() if ($cleanup_before_increment);
+ if (-e $restore_path) {
+ unlink $restore_path || die "can't remove $restore_path: $!\n";
+ }
+ symlink $path, $restore_path || die "can't create link $path -> $restore_path: $!\n";
- my $cmd = "cd $inc_tmp_dir && tar xfz $path";
- system($cmd) == 0 or die "can't execute: $cmd -- $?\n";
+
+ }
print "starting import into BackupPC pool\n";