r10862@llin: dpavlin | 2006-04-28 11:07:29 +0200
authordpavlin <dpavlin@8392b6e1-25fa-0310-8288-cc32f8e212ea>
Fri, 28 Apr 2006 09:07:41 +0000 (09:07 +0000)
committerdpavlin <dpavlin@8392b6e1-25fa-0310-8288-cc32f8e212ea>
Fri, 28 Apr 2006 09:07:41 +0000 (09:07 +0000)
 added $cleanup_before_increment option, see source for explanation (or don't use in general)

git-svn-id: svn+ssh://llin/home/dpavlin/private/svn/BackupPC/trunk@360 8392b6e1-25fa-0310-8288-cc32f8e212ea

bin/BackupPC_recover_from_increments

index 37c941e..5216efa 100755 (executable)
@@ -30,6 +30,11 @@ use BackupPC::Lib;
 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) );
@@ -56,11 +61,14 @@ die "host '$host' is not found, please add it to config/hosts configuration file
 # 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
 
@@ -108,6 +116,8 @@ sub restore_increment {
 
        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";