--- trunk/bin/BackupPC_recover_from_increments 2006/03/06 20:47:00 340 +++ trunk/bin/BackupPC_recover_from_increments 2006/03/07 10:17:56 342 @@ -1,5 +1,7 @@ #!/usr/bin/perl -w +use strict; + =head1 NAME BackupPC_recover_from_increments @@ -24,6 +26,8 @@ use lib "/data/backuppc/lib"; use BackupPC::Lib; +my $host = 'restore'; + # connect to BackupPC_server die("BackupPC::Lib->new failed\n") if ( !(my $bpc = BackupPC::Lib->new) ); @@ -41,9 +45,13 @@ print Dumper(\%Conf); +# check if host exists + +die "host $host is not found" unless ($bpc->HostInfoRead( $host )); + # create restore host configuration -my $restore_path = "$TopDir/$temp/restore.tar.gz"; +my $restore_path = "$Conf{InstallDir}/$Conf{GzipTempDir}/${host}-restore.tar.gz"; my $conf_restore = <<'_END_OF_CONF_'; @@ -63,7 +71,7 @@ $conf_restore =~ s/__restore_path__/$restore_path/gs; -my $config_file = "$bpc->{TopDir}/conf/restore.pl"; +my $config_file = "$bpc->{TopDir}/conf/${host}.pl"; open(my $host_fh, '>', $config_file) || die "can't open $config_file: $!"; print $host_fh $conf_restore || die "can't write configuration in $config_file: $!"; @@ -84,8 +92,9 @@ $bpc->ServerMesg("log User backuppc started restore of $path"); my $full = 0; - my $r = $bpc->ServerMesg("backup restore restore backuppc $full"); + my $r = $bpc->ServerMesg("backup $host $host backuppc $full"); print "backup --> $r"; + die $r if ($r =~ m/^error/); # Status_backup_in_progress # Status_idle @@ -99,6 +108,9 @@ eval "$s"; } $state = $Status{restore}->{state}; + + die $state if ($state =~ m/^error/); + if ($state ne $last_state) { print "\n$state"; #, Dumper($Status{restore}); } else {