my $host = 'restore';
my $share = '/etc';
+# this option will cleanup tar dump before import of each increment
+# WARNING: this will create increments which contain only new files, not
+# state of share in that particular moment! (it's fast, though)
+my $cleanup_before_increment = 0;
+
# connect to BackupPC_server
die("BackupPC::Lib->new failed\n") if ( !(my $bpc = BackupPC::Lib->new) );
# take care of temporary directory for increments
my $inc_tmp_dir = $Conf{IncrementTempDir} || die "need working directory in IncrementTempDir\n";
-rmtree($inc_tmp_dir) if (-e $inc_tmp_dir);
-mkpath($inc_tmp_dir);
+sub cleanup_inc_temp_dir {
+ rmtree($inc_tmp_dir) if (-e $inc_tmp_dir);
+ mkpath($inc_tmp_dir);
+}
print "# using $inc_tmp_dir for increment scratch space";
+cleanup_inc_temp_dir() if (! $cleanup_before_increment);
# create restore host configuration
print "restoring $path\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";