48 |
# check if host exists |
# check if host exists |
49 |
|
|
50 |
my $host_info = $bpc->HostInfoRead( $host ); |
my $host_info = $bpc->HostInfoRead( $host ); |
51 |
#print Dumper($host_info, $bpc->HostInfoRead( 'localhost' )); |
print Dumper($host_info, $bpc->HostInfoRead( 'localhost' )); |
52 |
die "host '$host' is not found\n" unless ($host_info->{$host}); |
die "host '$host' is not found, please add it to config/hosts configuration file\n" unless ($host_info->{$host}); |
53 |
|
|
54 |
# create restore host configuration |
# create restore host configuration |
55 |
|
|
64 |
|
|
65 |
# fake ping when restoring |
# fake ping when restoring |
66 |
$Conf{PingCmd} = '$pingPath -c 1 localhost', |
$Conf{PingCmd} = '$pingPath -c 1 localhost', |
67 |
|
$Conf{ClientNameAlias} = 'localhost'; |
68 |
|
|
69 |
$Conf{TarClientCmd} = 'zcat __restore_path__'; |
$Conf{TarClientCmd} = 'zcat __restore_path__'; |
70 |
|
|
85 |
sub restore_increment { |
sub restore_increment { |
86 |
my $path = shift || die "need path!"; |
my $path = shift || die "need path!"; |
87 |
|
|
88 |
|
if ($path !~ m/\.tar\.gz$/i) { |
89 |
|
print "skipping $path, not .tar.gz increment\n"; |
90 |
|
return; |
91 |
|
} |
92 |
|
|
93 |
print "working on $path\n"; |
print "working on $path\n"; |
94 |
|
|
95 |
if (-e $restore_path) { |
if (-e $restore_path) { |
96 |
unlink $restore_path || die "can't remove $restore_path: $!\n"; |
unlink $restore_path || die "can't remove $restore_path: $!\n"; |
97 |
} |
} |
98 |
link $path, $restore_path || die "can't create link $path -> $restore_path: $!\n"; |
symlink $path, $restore_path || die "can't create link $path -> $restore_path: $!\n"; |
99 |
|
|
100 |
|
my $user = $host_info->{$host}->{user} || die "can't get user for host $host"; |
101 |
|
|
102 |
$bpc->ServerMesg("log User backuppc started restore of $path"); |
$bpc->ServerMesg("log User $user started recovery from increment $path"); |
103 |
|
|
104 |
my $full = 0; |
my $full = 0; |
105 |
my $r = $bpc->ServerMesg("backup $host $host backuppc $full"); |
my $r = $bpc->ServerMesg("backup $host $host $user $full"); |
106 |
print "backup --> $r"; |
print "backup --> $r"; |
107 |
die $r if ($r =~ m/^error/); |
die $r if ($r =~ m/^error/); |
108 |
|
|
142 |
restore_increment( $File::Find::name ); |
restore_increment( $File::Find::name ); |
143 |
}, follow => 0 }, $restore_inc); |
}, follow => 0 }, $restore_inc); |
144 |
|
|
145 |
} elsif (-f $restore_inc && $restore_inc =~ m/\.tar\.gz$/i) { |
} elsif (-f $restore_inc) { |
146 |
restore_increment( $restore_inc ); |
restore_increment( $restore_inc ); |
147 |
} else { |
} else { |
148 |
warn "skipped: $restore_inc, not directory or .tar.gz increment\n"; |
warn "skipped: $restore_inc, not file or directory\n"; |
149 |
} |
} |
150 |
|
|
151 |
} |
} |