86 |
my $in_backup_increment; |
my $in_backup_increment; |
87 |
|
|
88 |
|
|
89 |
if ( !getopts("th:n:p:r:s:b:w:vd", \%opts) ) { |
if ( !getopts("th:n:p:r:s:b:w:vdf", \%opts) ) { |
90 |
print STDERR <<EOF; |
print STDERR <<EOF; |
91 |
usage: $0 [options] |
usage: $0 [options] |
92 |
Required options: |
Required options: |
102 |
-p pathAdd new path prefix |
-p pathAdd new path prefix |
103 |
-b BLOCKS BLOCKS x 512 bytes per record (default 20; same as tar) |
-b BLOCKS BLOCKS x 512 bytes per record (default 20; same as tar) |
104 |
-w writeBufSz write buffer size (default 1048576 = 1MB) |
-w writeBufSz write buffer size (default 1048576 = 1MB) |
105 |
|
-f overwrite existing parts |
106 |
-v verbose output |
-v verbose output |
107 |
-d debug output |
-d debug output |
108 |
EOF |
EOF |
225 |
|
|
226 |
print STDERR "backup_id: $backup_id working dir: $tar_dir, max uncompressed size $max_file_size bytes, tar $tar_file\n" if ($opts{d}); |
print STDERR "backup_id: $backup_id working dir: $tar_dir, max uncompressed size $max_file_size bytes, tar $tar_file\n" if ($opts{d}); |
227 |
|
|
228 |
|
if (-e $tar_path_final) { |
229 |
|
if ($opts{f}) { |
230 |
|
rmtree $tar_path_final || die "can't remove $tar_path_final: $!"; |
231 |
|
} else { |
232 |
|
die "$tar_path_final allready exists\n"; |
233 |
|
} |
234 |
|
} |
235 |
|
|
236 |
my $fh; |
my $fh; |
237 |
my $part = 0; |
my $part = 0; |
276 |
|
|
277 |
if ($arg->{close}) { |
if ($arg->{close}) { |
278 |
|
|
279 |
|
sub move($$) { |
280 |
|
my ($from,$to) = @_; |
281 |
|
print STDERR "# rename $from -> $to\n" if ($opts{d}); |
282 |
|
rename $from, $to || die "can't move $from -> $to: $!\n"; |
283 |
|
} |
284 |
|
|
285 |
if ($part == 1) { |
if ($part == 1) { |
286 |
print STDERR " single"; |
print STDERR " single"; |
287 |
rename "${tar_path}/1.tar.gz", "${tar_path_final}/.tar.gz" || die "can't move tar ${tar_path}: $! "; |
move("${tar_path}/1.tar.gz", "${tar_path_final}.tar.gz"); |
288 |
rename "${tar_path}/1.md5", "${tar_path_final}/.md5" || die "can't move md5 ${tar_path}: $! "; |
move("${tar_path}/1.md5", "${tar_path_final}.md5"); |
289 |
|
rmtree $tar_path or die "can't remove temporary dir $tar_path: $!"; |
290 |
} else { |
} else { |
291 |
print STDERR " [last]"; |
print STDERR " [last]"; |
292 |
rename "${tar_path}", "${tar_path_final}" || die "can't move tar ${tar_path}: $! "; |
move("${tar_path}", "${tar_path_final}"); |
293 |
} |
} |
294 |
|
|
295 |
$sth_inc_size->execute( |
$sth_inc_size->execute( |
355 |
if (seedCache($Host, $ShareName, $Num)) { |
if (seedCache($Host, $ShareName, $Num)) { |
356 |
archiveWrite($fh, '/'); |
archiveWrite($fh, '/'); |
357 |
archiveWriteHardLinks($fh); |
archiveWriteHardLinks($fh); |
358 |
|
new_tar_part( close => 1 ); |
359 |
} else { |
} else { |
360 |
print STDERR "NOTE: no files found for $Host:$ShareName, increment $Num\n" if ($opts{v}); |
print STDERR "NOTE: no files found for $Host:$ShareName, increment $Num\n" if ($opts{v}); |
361 |
$no_files = 1; |
# remove temporary files if there are no files |
|
} |
|
|
|
|
|
new_tar_part( close => 1 ); |
|
|
|
|
|
# remove temporary files if there are no files |
|
|
if ($no_files) { |
|
362 |
rmtree($tar_path); |
rmtree($tar_path); |
|
} elsif ($part == 1) { |
|
|
warn "FIXME: if there is only one part move to parent directory and rename"; |
|
363 |
} |
} |
364 |
|
|
365 |
# |
# |