X-Git-Url: http://git.rot13.org/?a=blobdiff_plain;f=bin%2FBackupPC_recover_from_increments;h=d8e505aa2c7600f9b9060b8f029daeb4dd5b4c6a;hb=f3bda3d68e97002413a6626d57f50f8e07146d45;hp=631bff35589fb9d5dc6dacfe915ac8e14681cb7a;hpb=59947f8fa8af3769b99faa2cbd5c4ea6e7acf666;p=BackupPC.git diff --git a/bin/BackupPC_recover_from_increments b/bin/BackupPC_recover_from_increments index 631bff3..d8e505a 100755 --- a/bin/BackupPC_recover_from_increments +++ b/bin/BackupPC_recover_from_increments @@ -1,5 +1,7 @@ #!/usr/bin/perl -w +use strict; + =head1 NAME BackupPC_recover_from_increments @@ -24,6 +26,8 @@ use Data::Dumper; 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) ); @@ -39,11 +43,17 @@ if ( $err ) { my $TopDir = $bpc->TopDir(); -print Dumper(\%Conf); +#print Dumper(\%Conf); + +# check if host exists + +my $host_info = $bpc->HostInfoRead( $host ); +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 -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_'; @@ -54,6 +64,7 @@ $Conf{TarIncrArgs} = ''; # fake ping when restoring $Conf{PingCmd} = '$pingPath -c 1 localhost', +$Conf{ClientNameAlias} = 'localhost'; $Conf{TarClientCmd} = 'zcat __restore_path__'; @@ -63,7 +74,7 @@ _END_OF_CONF_ $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: $!"; @@ -81,11 +92,14 @@ sub restore_increment { } link $path, $restore_path || die "can't create link $path -> $restore_path: $!\n"; - $bpc->ServerMesg("log User backuppc started restore of $path"); + my $user = $host_info->{$host}->{user} || die "can't get user for host $host"; + + $bpc->ServerMesg("log User $user started recovery from increment $path"); my $full = 0; - my $r = $bpc->ServerMesg("backup restore restore backuppc $full"); + my $r = $bpc->ServerMesg("backup $host $host $user $full"); print "backup --> $r"; + die $r if ($r =~ m/^error/); # Status_backup_in_progress # Status_idle @@ -99,6 +113,9 @@ sub restore_increment { eval "$s"; } $state = $Status{restore}->{state}; + + die $state if ($state =~ m/^error/); + if ($state ne $last_state) { print "\n$state"; #, Dumper($Status{restore}); } else {