--- trunk/bin/BackupPC_recover_from_increments 2006/04/26 11:10:48 352 +++ trunk/bin/BackupPC_recover_from_increments 2006/04/27 09:36:18 356 @@ -21,6 +21,7 @@ =cut use File::Find; +use File::Path; use Data::Dumper; use lib "/data/backuppc/lib"; @@ -49,21 +50,25 @@ # 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{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 @@ 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";