35 |
# state of share in that particular moment! (it's fast, though) |
# state of share in that particular moment! (it's fast, though) |
36 |
my $cleanup_before_increment = 0; |
my $cleanup_before_increment = 0; |
37 |
|
|
38 |
|
# this option will probably create wrong increments, but it's here for |
39 |
|
# testing and comparison. In short, don't use it! |
40 |
|
my $restore_via_temp_dir = 1; |
41 |
|
|
42 |
# connect to BackupPC_server |
# connect to BackupPC_server |
43 |
|
|
44 |
die("BackupPC::Lib->new failed\n") if ( !(my $bpc = BackupPC::Lib->new) ); |
my $bpc = BackupPC::Lib->new(undef, undef, 1) || die; |
45 |
my %Conf = $bpc->Conf(); |
my %Conf = $bpc->Conf(); |
46 |
|
|
47 |
$bpc->ChildInit(); |
$bpc->ChildInit(); |
74 |
print "# using $inc_tmp_dir for increment scratch space"; |
print "# using $inc_tmp_dir for increment scratch space"; |
75 |
cleanup_inc_temp_dir() if (! $cleanup_before_increment); |
cleanup_inc_temp_dir() if (! $cleanup_before_increment); |
76 |
|
|
77 |
|
my $restore_path = "$Conf{InstallDir}/$Conf{GzipTempDir}/${host}-restore.tar.gz"; |
78 |
|
|
79 |
# create restore host configuration |
# create restore host configuration |
80 |
|
|
81 |
my $conf_restore = <<'_END_OF_CONF_'; |
my $conf_restore = <<'_END_OF_CONF_'; |
92 |
|
|
93 |
#$Conf{TarIncrArgs} = ''; |
#$Conf{TarIncrArgs} = ''; |
94 |
#$Conf{ClientTimeout} = 600; |
#$Conf{ClientTimeout} = 600; |
95 |
|
|
96 |
|
_END_OF_CONF_ |
97 |
|
|
98 |
|
$conf_restore .= <<'_END_OF_CONF_' if (! $restore_via_temp_dir); |
99 |
|
|
100 |
#$Conf{TarClientCmd} = ''; |
#$Conf{TarClientCmd} = ''; |
101 |
#$Conf{TarFullArgs} = 'gzip -cdv __restore_path__'; |
#$Conf{TarFullArgs} = 'gzip -cdv __restore_path__'; |
102 |
|
|
103 |
$Conf{TarClientCmd} = '$tarPath -c -v -f - -C __inc_tmp_dir__ --totals'; |
# force BackupPC_tarExtract to produce output of tar -c -v -f - --totals |
104 |
|
# so that we can just pipe tar into it! |
105 |
|
$Conf{tarExtractEmulateTotals} = 1; |
106 |
|
$Conf{TarClientCmd} = 'zcat __restore_path__'; |
107 |
|
|
108 |
|
_END_OF_CONF_ |
109 |
|
|
110 |
1; |
$conf_restore .= <<'_END_OF_CONF_' if ($restore_via_temp_dir); |
111 |
|
|
112 |
|
$Conf{TarClientCmd} = '$tarPath -c -v -f - -C __inc_tmp_dir__ --totals'; |
113 |
|
|
114 |
_END_OF_CONF_ |
_END_OF_CONF_ |
115 |
|
|
116 |
$conf_restore =~ s/__share__/$share/gs; |
$conf_restore =~ s/__share__/$share/gs; |
117 |
$conf_restore =~ s/__inc_tmp_dir__/$inc_tmp_dir/gs; |
$conf_restore =~ s/__inc_tmp_dir__/$inc_tmp_dir/gs; |
118 |
|
$conf_restore =~ s/__restore_path__/$restore_path/gs; |
119 |
|
|
120 |
|
$conf_restore .= "\n1;\n"; |
121 |
|
|
122 |
my $config_file = "$bpc->{TopDir}/conf/${host}.pl"; |
my $config_file = "$bpc->{TopDir}/conf/${host}.pl"; |
123 |
|
|
135 |
return; |
return; |
136 |
} |
} |
137 |
|
|
138 |
print "restoring $path\n"; |
if ($restore_via_temp_dir) { |
139 |
|
|
140 |
|
print "restoring $path (extracting to create increment)\n"; |
141 |
|
|
142 |
|
cleanup_inc_temp_dir() if ($cleanup_before_increment); |
143 |
|
|
144 |
cleanup_inc_temp_dir() if ($cleanup_before_increment); |
my $cmd = "cd $inc_tmp_dir && tar xfz $path"; |
145 |
|
system($cmd) == 0 or die "can't execute: $cmd -- $?\n"; |
146 |
|
|
147 |
|
} else { |
148 |
|
|
149 |
my $cmd = "cd $inc_tmp_dir && tar xfz $path"; |
print "using $path to create increment\n"; |
150 |
system($cmd) == 0 or die "can't execute: $cmd -- $?\n"; |
|
151 |
|
if (-e $restore_path) { |
152 |
|
unlink $restore_path || die "can't remove $restore_path: $!\n"; |
153 |
|
} |
154 |
|
symlink $path, $restore_path || die "can't create link $path -> $restore_path: $!\n"; |
155 |
|
|
156 |
|
|
157 |
|
} |
158 |
|
|
159 |
print "starting import into BackupPC pool\n"; |
print "starting import into BackupPC pool\n"; |
160 |
|
|