r600@athlon: dpavlin | 2006-04-27 11:36:14 +0200
authordpavlin <dpavlin@8392b6e1-25fa-0310-8288-cc32f8e212ea>
Thu, 27 Apr 2006 09:36:18 +0000 (09:36 +0000)
committerdpavlin <dpavlin@8392b6e1-25fa-0310-8288-cc32f8e212ea>
Thu, 27 Apr 2006 09:36:18 +0000 (09:36 +0000)
 use IncrementTempDir as a scratch directory when recovering from increments

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

bin/BackupPC_recover_from_increments

index cabc49c..274ed28 100755 (executable)
@@ -21,6 +21,7 @@ quick hack to create BackupPC pool out of increments
 =cut
 
 use File::Find;
+use File::Path;
 use Data::Dumper;
 
 use lib "/data/backuppc/lib";
@@ -49,21 +50,25 @@ my $TopDir = $bpc->TopDir();
 # check if host exists
 
 my $host_info = $bpc->HostInfoRead( $host );
-print Dumper($host_info, $bpc->HostInfoRead( 'localhost' ));
+#print Dumper($host_info, $bpc->HostInfoRead( 'localhost' ));
 die "host '$host' is not found, please add it to config/hosts configuration file\n" unless ($host_info->{$host});
 
-# create restore host configuration
+# 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);
 
-my $restore_path = "$Conf{InstallDir}/$Conf{GzipTempDir}/restore.tar.gz";
+print "# using $inc_tmp_dir for increment scratch space";
+
+# create restore host configuration
 
 my $conf_restore = <<'_END_OF_CONF_';
 
 $Conf{XferMethod} = 'tar';
 $Conf{TarShareName} = '__share__';
 
-$Conf{TarFullArgs} = 'echo "full backups are not supported in restore!" ; exit 1';
-$Conf{TarIncrArgs} = '';
-
 # disable ping
 $Conf{PingCmd} = '';
 # work-around for Backup aborted because of CorrectHostCheck
@@ -71,14 +76,19 @@ $Conf{FixedIPNetBiosNameCheck} = 0;
 $Conf{NmbLookupCmd} = '';
 $Conf{ClientNameAlias} = 'localhost';
 
-$Conf{TarClientCmd} = 'zcat __restore_path__';
+#$Conf{TarIncrArgs} = '';
+#$Conf{ClientTimeout} = 600;
+#$Conf{TarClientCmd} = '';
+#$Conf{TarFullArgs} = 'gzip -cdv __restore_path__';
+
+$Conf{TarClientCmd} = '$tarPath -c -v -f - -C __inc_tmp_dir__ --totals';
 
 1;
 
 _END_OF_CONF_
 
-$conf_restore =~ s/__restore_path__/$restore_path/gs;
 $conf_restore =~ s/__share__/$share/gs;
+$conf_restore =~ s/__inc_tmp_dir__/$inc_tmp_dir/gs;
 
 my $config_file = "$bpc->{TopDir}/conf/${host}.pl";
 
@@ -92,16 +102,16 @@ sub restore_increment {
        my $path = shift || die "need path!";
 
        if ($path !~ m/\.tar\.gz$/i) {
-               print "skipping $path, not .tar.gz increment\n";
+               print "skipping $path, not .tar.gz increment\n";
                return;
        }
 
-       print "working on $path\n";
+       print "restoring $path\n";
 
-       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 xvfz $path";
+       system($cmd) == 0 or die "can't execute: $cmd -- $?\n";
+
+       print "starting import into BackupPC pool\n";
 
        my $user = $host_info->{$host}->{user} || die "can't get user for host $host";