#!/usr/bin/perl -w
+use strict;
+
=head1 NAME
BackupPC_recover_from_increments
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) );
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_';
# fake ping when restoring
$Conf{PingCmd} = '$pingPath -c 1 localhost',
+$Conf{ClientNameAlias} = 'localhost';
$Conf{TarClientCmd} = 'zcat __restore_path__';
$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: $!";
}
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
eval "$s";
}
$state = $Status{restore}->{state};
+
+ die $state if ($state =~ m/^error/);
+
if ($state ne $last_state) {
print "\n$state"; #, Dumper($Status{restore});
} else {