|
Lines 133-138
$::zsh_pipe_exit = '; x=(${pipestatus[@]
Link Here
|
| 133 |
# tar has a limit of this many chars in its volume label |
133 |
# tar has a limit of this many chars in its volume label |
| 134 |
$::tar_max_label = 99; |
134 |
$::tar_max_label = 99; |
| 135 |
|
135 |
|
|
|
136 |
# Define the prune hash to avoid warnings with perl 5.12 |
| 137 |
use vars qw( %prune ); |
| 138 |
|
| 136 |
# Get commandline flags |
139 |
# Get commandline flags |
| 137 |
%::opt = (); |
140 |
%::opt = (); |
| 138 |
if (! &::GetOptions(\%::opt, |
141 |
if (! &::GetOptions(\%::opt, |
|
Lines 269-274
if (($::mode !~ m/^(list|extract|restore
Link Here
|
| 269 |
untie(%::index); |
272 |
untie(%::index); |
| 270 |
} |
273 |
} |
| 271 |
|
274 |
|
|
|
275 |
system ('rm', '-rf', $cfg::tmpdir); |
| 272 |
exit(0); |
276 |
exit(0); |
| 273 |
|
277 |
|
| 274 |
###################################################################### |
278 |
###################################################################### |
|
Lines 441-447
sub backup_routine {
Link Here
|
| 441 |
# Get rid of trailing / |
445 |
# Get rid of trailing / |
| 442 |
$dir = &nuke_trailing_slash($dir); |
446 |
$dir = &nuke_trailing_slash($dir); |
| 443 |
|
447 |
|
| 444 |
# If level is icremental for the set, each dir might |
448 |
# If level is incremental for the set, each dir might |
| 445 |
# have a different numeric level |
449 |
# have a different numeric level |
| 446 |
if (!defined($::set_incremental)) { |
450 |
if (!defined($::set_incremental)) { |
| 447 |
$level = $::level; |
451 |
$level = $::level; |
|
Lines 687-692
sub backup {
Link Here
|
| 687 |
$filename .= ".zip"; |
691 |
$filename .= ".zip"; |
| 688 |
} elsif ($cfg::compress eq "compress") { |
692 |
} elsif ($cfg::compress eq "compress") { |
| 689 |
$filename .= ".Z"; |
693 |
$filename .= ".Z"; |
|
|
694 |
} elsif ($cfg::compress eq "lzma") { |
| 695 |
$filename .= ".lzma"; |
| 690 |
} |
696 |
} |
| 691 |
} elsif ($cfg::type eq "afio") { |
697 |
} elsif ($cfg::type eq "afio") { |
| 692 |
# tag these a little different, the archive file itself isn't a |
698 |
# tag these a little different, the archive file itself isn't a |
|
Lines 701-706
sub backup {
Link Here
|
| 701 |
$filename .= "-zip"; |
707 |
$filename .= "-zip"; |
| 702 |
} elsif ($cfg::compress eq "compress") { |
708 |
} elsif ($cfg::compress eq "compress") { |
| 703 |
$filename .= "-Z"; |
709 |
$filename .= "-Z"; |
|
|
710 |
} elsif ($cfg::compress eq "lzma") { |
| 711 |
$filename .= "-lzma"; |
| 704 |
} |
712 |
} |
| 705 |
} |
713 |
} |
| 706 |
|
714 |
|
|
Lines 811-816
sub backup {
Link Here
|
| 811 |
($remove, @cmds) = &backup_filelist($label, $localdir, $title, $level, $remote); |
819 |
($remove, @cmds) = &backup_filelist($label, $localdir, $title, $level, $remote); |
| 812 |
} |
820 |
} |
| 813 |
|
821 |
|
|
|
822 |
if(defined($remote)) { |
| 823 |
# create our temporary directory as first remote command |
| 824 |
unshift(@cmds, &maybe_remote_cmd("$::path{mkdir} -p $cfg::tmpdir", $remote)); |
| 825 |
} |
| 826 |
|
| 814 |
# Nuke any tmp files used in the above routines |
827 |
# Nuke any tmp files used in the above routines |
| 815 |
if ($remove ne '') { |
828 |
if ($remove ne '') { |
| 816 |
push(@cmds, &maybe_remote_cmd("$::path{rm} -f $remove", $remote)); |
829 |
push(@cmds, &maybe_remote_cmd("$::path{rm} -f $remove", $remote)); |
|
Lines 827-832
sub backup {
Link Here
|
| 827 |
push(@cmds, &maybe_remote_cmd("$::path{rm} -f $pkglist", $remote)); |
840 |
push(@cmds, &maybe_remote_cmd("$::path{rm} -f $pkglist", $remote)); |
| 828 |
} |
841 |
} |
| 829 |
} |
842 |
} |
|
|
843 |
|
| 844 |
if(defined($remote)) { |
| 845 |
# remove temporary directory as our last remote command |
| 846 |
push(@cmds, &maybe_remote_cmd("$::path{rm} -rf $cfg::tmpdir", $remote)); |
| 847 |
} |
| 830 |
|
848 |
|
| 831 |
# Strip multiple spaces |
849 |
# Strip multiple spaces |
| 832 |
foreach my $cmd (@cmds) { |
850 |
foreach my $cmd (@cmds) { |
|
Lines 1035-1041
sub backup_dump {
Link Here
|
| 1035 |
} else { |
1053 |
} else { |
| 1036 |
$prunekey = $dir; |
1054 |
$prunekey = $dir; |
| 1037 |
} |
1055 |
} |
| 1038 |
if (defined(%{$::prune{$prunekey}})) { |
1056 |
if (defined($prune{$prunekey})) { |
| 1039 |
&log("| NOTE: \$prune is ignored for type=dump"); |
1057 |
&log("| NOTE: \$prune is ignored for type=dump"); |
| 1040 |
} |
1058 |
} |
| 1041 |
|
1059 |
|
|
Lines 1140-1146
sub backup_afio {
Link Here
|
| 1140 |
$cmd .= "$::path{afio} -o "; |
1158 |
$cmd .= "$::path{afio} -o "; |
| 1141 |
$cmd .= "$no_compress "; |
1159 |
$cmd .= "$no_compress "; |
| 1142 |
$cmd .= "-z "; |
1160 |
$cmd .= "-z "; |
| 1143 |
$cmd .= "-1 m "; |
1161 |
$cmd .= "-1 mC "; |
| 1144 |
$cmd .= "$::afio_z_flag "; |
1162 |
$cmd .= "$::afio_z_flag "; |
| 1145 |
$cmd .= "$::afio_verb_flag "; |
1163 |
$cmd .= "$::afio_verb_flag "; |
| 1146 |
$cmd .= "$::afio_sparse_flag "; |
1164 |
$cmd .= "$::afio_sparse_flag "; |
|
Lines 1286-1293
sub backup_copy_cpio {
Link Here
|
| 1286 |
$cmd .= "$::unz"; |
1304 |
$cmd .= "$::unz"; |
| 1287 |
} |
1305 |
} |
| 1288 |
$cmd .= "("; |
1306 |
$cmd .= "("; |
| 1289 |
$cmd .= "mkdir -p $::device ; "; |
1307 |
$cmd .= "mkdir -p \"$::device\" ; "; |
| 1290 |
$cmd .= "cd $::device ; "; |
1308 |
$cmd .= "cd \"$::device\" ; "; |
| 1291 |
$cmd .= "$::path{cpio} -i "; |
1309 |
$cmd .= "$::path{cpio} -i "; |
| 1292 |
$cmd .= "-m "; |
1310 |
$cmd .= "-m "; |
| 1293 |
$cmd .= "-d "; |
1311 |
$cmd .= "-d "; |
|
Lines 1336-1344
sub backup_copy_rsync {
Link Here
|
| 1336 |
|
1354 |
|
| 1337 |
# Have to take leading './' off to make rsync's include/exclude work right |
1355 |
# Have to take leading './' off to make rsync's include/exclude work right |
| 1338 |
$cmd .= " | $::path{sed} -e \"s/\\.\\///g\" | "; |
1356 |
$cmd .= " | $::path{sed} -e \"s/\\.\\///g\" | "; |
| 1339 |
|
|
|
| 1340 |
$cmd .= "$::path{rsync} "; |
1357 |
$cmd .= "$::path{rsync} "; |
| 1341 |
$cmd .= "--include-from=- --exclude=* "; |
1358 |
$cmd .= "--files-from=- "; |
| 1342 |
$cmd .= "--archive "; |
1359 |
$cmd .= "--archive "; |
| 1343 |
$cmd .= "$::rsync_verb_flag "; |
1360 |
$cmd .= "$::rsync_verb_flag "; |
| 1344 |
$cmd .= "--delete --delete-excluded "; |
1361 |
$cmd .= "--delete --delete-excluded "; |
|
Lines 1353-1359
sub backup_copy_rsync {
Link Here
|
| 1353 |
$cmd .= "$remote:"; |
1370 |
$cmd .= "$remote:"; |
| 1354 |
} |
1371 |
} |
| 1355 |
} |
1372 |
} |
| 1356 |
$cmd .= "$dir/ $::device"; |
1373 |
$cmd .= "\"$dir/\" \"$::device\""; |
| 1357 |
|
1374 |
|
| 1358 |
push(@cmds, $cmd); |
1375 |
push(@cmds, $cmd); |
| 1359 |
|
1376 |
|
|
Lines 1643-1649
sub backup_ar {
Link Here
|
| 1643 |
my $tmpfile = "$cfg::tmpdir/ar.$PROCESS_ID"; |
1660 |
my $tmpfile = "$cfg::tmpdir/ar.$PROCESS_ID"; |
| 1644 |
my $remove = ''; |
1661 |
my $remove = ''; |
| 1645 |
|
1662 |
|
| 1646 |
&log("| NOTE: ar archives will not descend directories"); |
1663 |
&log("| NOTE: ar archives will not recurse into subdirectories,"); |
|
|
1664 |
&log("| which makes them inappropriate for most backups."); |
| 1665 |
&log("| Be sure this is what you want."); |
| 1647 |
|
1666 |
|
| 1648 |
if (defined($remote) and ($level != 0)) { |
1667 |
if (defined($remote) and ($level != 0)) { |
| 1649 |
my $time = &get_last_date($label, $level, 'numeric'); |
1668 |
my $time = &get_last_date($label, $level, 'numeric'); |
|
Lines 1667-1677
sub backup_ar {
Link Here
|
| 1667 |
$cmd = "cd \"$dir\" && "; |
1686 |
$cmd = "cd \"$dir\" && "; |
| 1668 |
$cmd .= &file_list_cmd( $dir, $stamp, 'newline', $level, $remote, '-maxdepth 1 ! -type d'); |
1687 |
$cmd .= &file_list_cmd( $dir, $stamp, 'newline', $level, $remote, '-maxdepth 1 ! -type d'); |
| 1669 |
$cmd .= "> $filelist; "; |
1688 |
$cmd .= "> $filelist; "; |
|
|
1689 |
# Escape any spaces in filenames. |
| 1690 |
$cmd .= "$::path{sed} -i -e 's/ /\\\\ /g' $filelist; "; |
| 1670 |
|
1691 |
|
| 1671 |
$cmd .= "$::path{ar} rc"; |
1692 |
$cmd .= "$::path{ar} rc"; |
| 1672 |
$cmd .= "$::ar_verb_flag "; |
1693 |
$cmd .= "$::ar_verb_flag "; |
| 1673 |
$cmd .= "$tmpfile "; |
1694 |
$cmd .= "$tmpfile "; |
| 1674 |
$cmd .= "`$::path{cat} $filelist`"; |
1695 |
$cmd .= "\@$filelist "; |
| 1675 |
$cmd .= "; $::path{cat} $tmpfile $::z"; |
1696 |
$cmd .= "; $::path{cat} $tmpfile $::z"; |
| 1676 |
|
1697 |
|
| 1677 |
# Buffer both sides if remote |
1698 |
# Buffer both sides if remote |
|
Lines 1785-1796
sub backup_lha {
Link Here
|
| 1785 |
|
1806 |
|
| 1786 |
$cmd = "cd \"$dir\" && "; |
1807 |
$cmd = "cd \"$dir\" && "; |
| 1787 |
$cmd .= &file_list_cmd( $dir, $stamp, 'newline', $level, $remote); |
1808 |
$cmd .= &file_list_cmd( $dir, $stamp, 'newline', $level, $remote); |
| 1788 |
$cmd .= "> $filelist; "; |
1809 |
$cmd .= " | $::path{lha} a"; |
| 1789 |
|
|
|
| 1790 |
$cmd .= "$::path{lha} a"; |
| 1791 |
$cmd .= "$::lha_verb_flag "; |
1810 |
$cmd .= "$::lha_verb_flag "; |
| 1792 |
$cmd .= "$tmpfile "; |
1811 |
$cmd .= "$tmpfile "; |
| 1793 |
$cmd .= "`$::path{cat} $filelist`"; |
|
|
| 1794 |
$cmd .= "; $::path{cat} $tmpfile $::z"; |
1812 |
$cmd .= "; $::path{cat} $tmpfile $::z"; |
| 1795 |
|
1813 |
|
| 1796 |
# Buffer both sides if remote |
1814 |
# Buffer both sides if remote |
|
Lines 2670-2676
sub optioncheck {
Link Here
|
| 2670 |
} |
2688 |
} |
| 2671 |
|
2689 |
|
| 2672 |
# Flag old config file |
2690 |
# Flag old config file |
| 2673 |
if (defined(@cfg::filesystems) or defined($cfg::mt_var_blksize)) { |
2691 |
if (@cfg::filesystems or defined($cfg::mt_var_blksize)) { |
| 2674 |
# so strict shuts up |
2692 |
# so strict shuts up |
| 2675 |
my $junk = @cfg::filesystems; |
2693 |
my $junk = @cfg::filesystems; |
| 2676 |
$junk = $cfg::mt_var_blksize; |
2694 |
$junk = $cfg::mt_var_blksize; |
|
Lines 2700-2706
sub optioncheck {
Link Here
|
| 2700 |
# First check if things are defined in the config file |
2718 |
# First check if things are defined in the config file |
| 2701 |
# Checks exist, true/false, or one of options |
2719 |
# Checks exist, true/false, or one of options |
| 2702 |
&checkvar(\$cfg::type,'type','dump afio cpio tar star pax zip ar shar lha copy rsync filelist','tar'); |
2720 |
&checkvar(\$cfg::type,'type','dump afio cpio tar star pax zip ar shar lha copy rsync filelist','tar'); |
| 2703 |
&checkvar(\$cfg::compress,'compress','gzip bzip2 lzop compress zip false hardware','gzip'); |
2721 |
&checkvar(\$cfg::compress,'compress','gzip bzip2 lzop compress zip false hardware lzma','gzip'); |
| 2704 |
&checkvar(\$cfg::compr_level,'compr_level','exist','4'); |
2722 |
&checkvar(\$cfg::compr_level,'compr_level','exist','4'); |
| 2705 |
&checkvar(\$cfg::verbose,'verbose','bool','true'); |
2723 |
&checkvar(\$cfg::verbose,'verbose','bool','true'); |
| 2706 |
&checkvar(\$cfg::sparse,'sparse','bool','true'); |
2724 |
&checkvar(\$cfg::sparse,'sparse','bool','true'); |
|
Lines 2750-2757
sub optioncheck {
Link Here
|
| 2750 |
$::path{'find'} = &checkinpath('find'); |
2768 |
$::path{'find'} = &checkinpath('find'); |
| 2751 |
$::path{'dd'} = &checkinpath('dd'); |
2769 |
$::path{'dd'} = &checkinpath('dd'); |
| 2752 |
$::path{'printf'} = &checkinpath('printf'); |
2770 |
$::path{'printf'} = &checkinpath('printf'); |
|
|
2771 |
$::path{'mkdir'} = &checkinpath('mkdir'); |
| 2772 |
$::path{'sed'} = &checkinpath('sed'); |
| 2753 |
|
2773 |
|
| 2754 |
push(@::remoteprogs,($::path{'touch'},$::path{'rm'},$::path{'find'},$::path{'printf'})); |
2774 |
push(@::remoteprogs,($::path{'touch'},$::path{'rm'},$::path{'find'},$::path{'printf'},$::path{'mkdir'})); |
| 2755 |
|
2775 |
|
| 2756 |
# Check device (or dir) |
2776 |
# Check device (or dir) |
| 2757 |
$::ftape = 0; |
2777 |
$::ftape = 0; |
|
Lines 3001-3006
sub optioncheck {
Link Here
|
| 3001 |
$::z = " | $::path{zip} -$cfg::compr_level - -"; |
3021 |
$::z = " | $::path{zip} -$cfg::compr_level - -"; |
| 3002 |
$::unz = "$::path{funzip} | "; |
3022 |
$::unz = "$::path{funzip} | "; |
| 3003 |
} |
3023 |
} |
|
|
3024 |
} elsif ($cfg::compress eq "lzma") { |
| 3025 |
$::path{'lzma'} = &checkinpath($cfg::compress); |
| 3026 |
push(@::remoteprogs, $::path{$cfg::compress}); |
| 3027 |
if ($cfg::compr_level !~ m/^[0123456789]$/) { |
| 3028 |
push(@::errors,"\$compr_level must be set to 1-9"); |
| 3029 |
} else { |
| 3030 |
$::z = " | $::path{$cfg::compress} -$cfg::compr_level "; |
| 3031 |
} |
| 3032 |
$::unz = "$::path{$cfg::compress} -d | "; |
| 3033 |
|
| 3004 |
} else { |
3034 |
} else { |
| 3005 |
$::z = ""; |
3035 |
$::z = ""; |
| 3006 |
$::unz = ""; |
3036 |
$::unz = ""; |
|
Lines 3059-3070
sub optioncheck {
Link Here
|
| 3059 |
$::read_cmd = "$bufcmd $read_flags"; |
3089 |
$::read_cmd = "$bufcmd $read_flags"; |
| 3060 |
|
3090 |
|
| 3061 |
} elsif ($cfg::buffer eq "mbuffer") { |
3091 |
} elsif ($cfg::buffer eq "mbuffer") { |
| 3062 |
|
|
|
| 3063 |
$::path{'mbuffer'} = &checkinpath('mbuffer'); |
3092 |
$::path{'mbuffer'} = &checkinpath('mbuffer'); |
| 3064 |
push(@::remoteprogs, $::path{'mbuffer'}); |
3093 |
push(@::remoteprogs, $::path{'mbuffer'}); |
| 3065 |
|
3094 |
|
| 3066 |
my $megs = $cfg::buffer_megs . "M"; |
3095 |
my $megs = $cfg::buffer_megs . "M"; |
| 3067 |
my $bufcmd = "$::path{mbuffer} -q -m $megs -p $cfg::buffer_fill_pct $mbuffer_blk_flag "; |
3096 |
my $bufcmd = "$::path{mbuffer} -q -m $megs -P $cfg::buffer_fill_pct $mbuffer_blk_flag "; |
| 3068 |
|
3097 |
|
| 3069 |
$::buffer_cmd = " | $bufcmd"; |
3098 |
$::buffer_cmd = " | $bufcmd"; |
| 3070 |
$::write_cmd = "$bufcmd -f -o "; |
3099 |
$::write_cmd = "$bufcmd -f -o "; |
|
Lines 3075-3081
sub optioncheck {
Link Here
|
| 3075 |
} |
3104 |
} |
| 3076 |
} |
3105 |
} |
| 3077 |
} else { |
3106 |
} else { |
| 3078 |
|
|
|
| 3079 |
# If buffering disabled, use dd or cat depending on if blocking turned off on not |
3107 |
# If buffering disabled, use dd or cat depending on if blocking turned off on not |
| 3080 |
if ($cfg::blksize eq '0') { |
3108 |
if ($cfg::blksize eq '0') { |
| 3081 |
$::buffer_cmd = ""; |
3109 |
$::buffer_cmd = ""; |
|
Lines 3230-3236
sub optioncheck {
Link Here
|
| 3230 |
push(@::remoteprogs, $::path{'afio'}); |
3258 |
push(@::remoteprogs, $::path{'afio'}); |
| 3231 |
|
3259 |
|
| 3232 |
# Compress flag for afio must be handled differently |
3260 |
# Compress flag for afio must be handled differently |
| 3233 |
if ($cfg::compress =~ m/^(gzip|bzip2|lzop|compress|zip)$/) { |
3261 |
if ($cfg::compress =~ m/^(gzip|bzip2|lzop|compress|zip|lzma)$/) { |
| 3234 |
|
3262 |
|
| 3235 |
if ($cfg::compress eq "gzip") { |
3263 |
if ($cfg::compress eq "gzip") { |
| 3236 |
$::afio_z_flag = "-P $::path{$cfg::compress} -Q -$cfg::compr_level -Z"; |
3264 |
$::afio_z_flag = "-P $::path{$cfg::compress} -Q -$cfg::compr_level -Z"; |
|
Lines 3252-3257
sub optioncheck {
Link Here
|
| 3252 |
$::afio_z_flag = "-P $::path{$cfg::compress} -Q -c -Z"; |
3280 |
$::afio_z_flag = "-P $::path{$cfg::compress} -Q -c -Z"; |
| 3253 |
$::afio_unz_flag = "-P $::path{$cfg::compress} -Q -d -Q -c -Z"; |
3281 |
$::afio_unz_flag = "-P $::path{$cfg::compress} -Q -d -Q -c -Z"; |
| 3254 |
|
3282 |
|
|
|
3283 |
} elsif ($cfg::compress eq "lzma") { |
| 3284 |
$::afio_z_flag = "-P $::path{$cfg::compress} -Q -$cfg::compr_level -Z"; |
| 3285 |
$::afio_unz_flag = "-P $::path{$cfg::compress} -Q -d -Z"; |
| 3286 |
|
| 3255 |
} |
3287 |
} |
| 3256 |
$::unz = ""; # Reset & just use this for reading the archive file. |
3288 |
$::unz = ""; # Reset & just use this for reading the archive file. |
| 3257 |
|
3289 |
|
|
Lines 3415-3421
sub optioncheck {
Link Here
|
| 3415 |
$::path{'lha'} = &checkinpath('lha'); |
3447 |
$::path{'lha'} = &checkinpath('lha'); |
| 3416 |
push(@::remoteprogs, $::path{'lha'}); |
3448 |
push(@::remoteprogs, $::path{'lha'}); |
| 3417 |
|
3449 |
|
| 3418 |
if ($cfg::compress =~ /^(gzip|bzip2|lzop|compress|zip)$/) { |
3450 |
if ($cfg::compress =~ /^(gzip|bzip2|lzop|compress|zip|lzma)$/) { |
| 3419 |
warn("Using type \"lha\" with compress=$cfg::compress makes no sense"); |
3451 |
warn("Using type \"lha\" with compress=$cfg::compress makes no sense"); |
| 3420 |
warn("Setting compression to false"); |
3452 |
warn("Setting compression to false"); |
| 3421 |
$::unz = ""; |
3453 |
$::unz = ""; |
|
Lines 3442-3447
sub optioncheck {
Link Here
|
| 3442 |
push(@::errors,"\$tmpdir $cfg::tmpdir is not writable"); |
3474 |
push(@::errors,"\$tmpdir $cfg::tmpdir is not writable"); |
| 3443 |
} |
3475 |
} |
| 3444 |
|
3476 |
|
|
|
3477 |
$cfg::hostname = `hostname`; |
| 3478 |
chomp($cfg::hostname); |
| 3479 |
|
| 3480 |
# Use a subdirectory of the user-specified directory as our tmpdir |
| 3481 |
# Also note that we make it closer to globally unique as we sometimes |
| 3482 |
# use this variable for remote systems, so PID isn't enough |
| 3483 |
$cfg::tmpdir = $cfg::tmpdir .'/flexbackup.'.$$.'.'.$cfg::hostname; |
| 3484 |
mkdir ($cfg::tmpdir) || die "Can't create temporary directory, $!"; |
| 3485 |
|
| 3445 |
# Levels |
3486 |
# Levels |
| 3446 |
if (defined($::opt{'level'}) and |
3487 |
if (defined($::opt{'level'}) and |
| 3447 |
(defined($::opt{'incremental'}) or |
3488 |
(defined($::opt{'incremental'}) or |
|
Lines 3781-3787
sub maybe_get_filename {
Link Here
|
| 3781 |
|
3822 |
|
| 3782 |
# Try and guess file types and commpression scheme |
3823 |
# Try and guess file types and commpression scheme |
| 3783 |
# might as well since we are reading from a file in this case |
3824 |
# might as well since we are reading from a file in this case |
| 3784 |
if ($file =~ m/\.(dump|cpio|tar|star|pax|a|shar|filelist)\.(gz|bz2|lzo|Z|zip)$/) { |
3825 |
if ($file =~ m/\.(dump|cpio|tar|star|pax|a|shar|filelist)\.(gz|bz2|lzo|Z|zip|lzma)$/) { |
| 3785 |
$cfg::type = $1; |
3826 |
$cfg::type = $1; |
| 3786 |
$cfg::compress = $2; |
3827 |
$cfg::compress = $2; |
| 3787 |
$cfg::type =~ s/^a$/ar/; |
3828 |
$cfg::type =~ s/^a$/ar/; |
|
Lines 3789-3804
sub maybe_get_filename {
Link Here
|
| 3789 |
$cfg::compress =~ s/bz2/bzip2/; |
3830 |
$cfg::compress =~ s/bz2/bzip2/; |
| 3790 |
$cfg::compress =~ s/lzo/lzop/; |
3831 |
$cfg::compress =~ s/lzo/lzop/; |
| 3791 |
$cfg::compress =~ s/Z/compress/; |
3832 |
$cfg::compress =~ s/Z/compress/; |
|
|
3833 |
$cfg::compress =~ s/lzma/lzma/; |
| 3792 |
&log("| Auto-set to type=$cfg::type compress=$cfg::compress"); |
3834 |
&log("| Auto-set to type=$cfg::type compress=$cfg::compress"); |
| 3793 |
&optioncheck(); # redo to set a few variables over |
3835 |
&optioncheck(); # redo to set a few variables over |
| 3794 |
|
3836 |
|
| 3795 |
} elsif ($file =~ m/\.afio-(gz|bz2|lzo|Z|zip)$/) { |
3837 |
} elsif ($file =~ m/\.afio-(gz|bz2|lzo|Z|zip|lzma)$/) { |
| 3796 |
$cfg::type = "afio"; |
3838 |
$cfg::type = "afio"; |
| 3797 |
$cfg::compress = $1; |
3839 |
$cfg::compress = $1; |
| 3798 |
$cfg::compress =~ s/gz/gzip/; |
3840 |
$cfg::compress =~ s/gz/gzip/; |
| 3799 |
$cfg::compress =~ s/bz2/bzip2/; |
3841 |
$cfg::compress =~ s/bz2/bzip2/; |
| 3800 |
$cfg::compress =~ s/lzo/lzop/; |
3842 |
$cfg::compress =~ s/lzo/lzop/; |
| 3801 |
$cfg::compress =~ s/Z/compress/; |
3843 |
$cfg::compress =~ s/Z/compress/; |
|
|
3844 |
$cfg::compress =~ s/lzma/lzma/; |
| 3802 |
&log("| Auto-set to type=$cfg::type compress=$cfg::compress"); |
3845 |
&log("| Auto-set to type=$cfg::type compress=$cfg::compress"); |
| 3803 |
&optioncheck(); # redo to set a few variables over |
3846 |
&optioncheck(); # redo to set a few variables over |
| 3804 |
|
3847 |
|
|
Lines 4841-4865
sub file_list_cmd {
Link Here
|
| 4841 |
} else { |
4884 |
} else { |
| 4842 |
$prunekey = $dir; |
4885 |
$prunekey = $dir; |
| 4843 |
} |
4886 |
} |
| 4844 |
|
4887 |
if (defined($prune{$prunekey})) { |
| 4845 |
if (defined(%{$::prune{$prunekey}})) { |
4888 |
my $rex; |
| 4846 |
# FreeBSD needs -E (above) and no backslashes around the (|) chars |
4889 |
# FreeBSD needs -E (above) and no backslashes around the (|) chars |
| 4847 |
if ($::uname =~ /FreeBSD/) { |
4890 |
if ($::uname =~ /FreeBSD/) { |
| 4848 |
$cmd .= '-regex "\./('; |
4891 |
$rex = '"\./('; |
| 4849 |
$cmd .= join('|', keys %{$::prune{$prunekey}}); |
4892 |
$rex .= join('|', keys %{$::prune{$prunekey}}); |
| 4850 |
$cmd .= ')/.*" '; |
4893 |
$rex .= ')"'; |
| 4851 |
} else { |
4894 |
} else { |
| 4852 |
$cmd .= '-regex "\./\('; |
4895 |
$rex = '"\./\('; |
| 4853 |
$cmd .= join('\|', keys %{$::prune{$prunekey}}); |
4896 |
$rex .= join('\|', keys %{$::prune{$prunekey}}); |
| 4854 |
$cmd .= '\)/.*" '; |
4897 |
$rex .= '\)"'; |
| 4855 |
} |
4898 |
} |
| 4856 |
$cmd .= '-prune -o '; |
4899 |
# Show what the darn thing is constructing for prune expressions. |
|
|
4900 |
(my $temp = $rex) =~ s/\\([()|])/$1/g; |
| 4901 |
&log("| \"find\" regex for pruning (shell escaping omitted for clarity) is:"); |
| 4902 |
&log("| $temp"); |
| 4903 |
$cmd .= '-regex ' . $rex . ' -prune -o '; |
| 4857 |
} else { |
4904 |
} else { |
|
|
4905 |
# Show what the darn thing is constructing for prune expressions. |
| 4906 |
&log("| No pruning defined for this tree."); |
| 4858 |
# Can't use find -depth with -prune (see single unix spec etc) |
4907 |
# Can't use find -depth with -prune (see single unix spec etc) |
| 4859 |
# (not toally required anyway, only if you are archiving dirs you |
4908 |
# (not toally required anyway, only if you are archiving dirs you |
| 4860 |
# don't have permissions on and are running as non-root) |
4909 |
# don't have permissions on and are running as non-root) |
| 4861 |
$cmd .= "-depth "; |
4910 |
$cmd .= "-depth "; |
| 4862 |
} |
4911 |
} |
|
|
4912 |
&line(); |
| 4863 |
|
4913 |
|
| 4864 |
$cmd .= "$::mountpoint_flag "; |
4914 |
$cmd .= "$::mountpoint_flag "; |
| 4865 |
$cmd .= "! -type s "; |
4915 |
$cmd .= "! -type s "; |
|
Lines 5229-5234
sub test_bufferprog {
Link Here
|
| 5229 |
my $tmp_script = "$cfg::tmpdir/buftest.$host.$PROCESS_ID.sh"; |
5279 |
my $tmp_script = "$cfg::tmpdir/buftest.$host.$PROCESS_ID.sh"; |
| 5230 |
my $retval = 0; |
5280 |
my $retval = 0; |
| 5231 |
my $pipecmd; |
5281 |
my $pipecmd; |
|
|
5282 |
my $explicit_success; |
| 5232 |
|
5283 |
|
| 5233 |
$buffer_cmd =~ s:^\s*\|\s*::; |
5284 |
$buffer_cmd =~ s:^\s*\|\s*::; |
| 5234 |
$buffer_cmd =~ s:\s*\|\s*$::; |
5285 |
$buffer_cmd =~ s:\s*\|\s*$::; |
|
Lines 5236-5249
sub test_bufferprog {
Link Here
|
| 5236 |
# Create a script which tests the buffer program |
5287 |
# Create a script which tests the buffer program |
| 5237 |
open(SCR,"> $tmp_script") || die; |
5288 |
open(SCR,"> $tmp_script") || die; |
| 5238 |
print SCR "#!/bin/sh\n"; |
5289 |
print SCR "#!/bin/sh\n"; |
| 5239 |
print SCR "tmp_data=/tmp/bufftest\$\$.txt\n"; |
5290 |
print SCR "tmp_data=\$(mktemp $cfg::tmpdir/data.XXXXXXXXXX)\n"; |
| 5240 |
print SCR "tmp_err=/tmp/bufftest\$\$.err\n"; |
5291 |
print SCR "tmp_err=\$(mktemp $cfg::tmpdir/err.XXXXXXXXXX)\n"; |
| 5241 |
print SCR "echo testme > \$tmp_data\n"; |
5292 |
print SCR "echo testme > \$tmp_data\n"; |
| 5242 |
print SCR "$buffer_cmd > /dev/null 2> \$tmp_err < \$tmp_data\n"; |
5293 |
print SCR "$buffer_cmd > /dev/null 2> \$tmp_err < \$tmp_data\n"; |
| 5243 |
print SCR "res=\$?\n"; |
5294 |
print SCR "res=\$?\n"; |
| 5244 |
print SCR "out=\`cat \$tmp_err\`\n"; |
5295 |
print SCR "out=\`cat \$tmp_err\`\n"; |
| 5245 |
print SCR "if [ \$res -eq 0 ]; then\n"; |
5296 |
print SCR "if [ \$res -eq 0 ]; then\n"; |
| 5246 |
print SCR " echo successful\n"; |
5297 |
print SCR " echo \"successful\"\n"; |
| 5247 |
print SCR "else\n"; |
5298 |
print SCR "else\n"; |
| 5248 |
print SCR " echo \"unsuccessful: exit code \$res: \$out\" \n"; |
5299 |
print SCR " echo \"unsuccessful: exit code \$res: \$out\" \n"; |
| 5249 |
print SCR "fi\n"; |
5300 |
print SCR "fi\n"; |
|
Lines 5254-5267
sub test_bufferprog {
Link Here
|
| 5254 |
print $::msg "| Checking '$cfg::buffer' on this machine... "; |
5305 |
print $::msg "| Checking '$cfg::buffer' on this machine... "; |
| 5255 |
$pipecmd = "sh $tmp_script "; |
5306 |
$pipecmd = "sh $tmp_script "; |
| 5256 |
} else { |
5307 |
} else { |
|
|
5308 |
$pipecmd = |
| 5309 |
"$::remoteshell $host '$::path{mkdir} -p $cfg::tmpdir'; " . |
| 5310 |
"cat $tmp_script | ($::remoteshell $host 'cat > $tmp_script; " . |
| 5311 |
"sh $tmp_script; rm -rf $cfg::tmpdir')"; |
| 5257 |
print $::msg "| Checking '$cfg::buffer' on host $host... "; |
5312 |
print $::msg "| Checking '$cfg::buffer' on host $host... "; |
| 5258 |
$pipecmd = "cat $tmp_script | ($::remoteshell $host 'cat > $tmp_script; sh $tmp_script; rm -f $tmp_script')"; |
|
|
| 5259 |
} |
5313 |
} |
| 5260 |
|
5314 |
|
| 5261 |
if (!defined($::debug)) { |
5315 |
if (!defined($::debug)) { |
| 5262 |
|
|
|
| 5263 |
open(PIPE,"$pipecmd |") || die; |
5316 |
open(PIPE,"$pipecmd |") || die; |
|
|
5317 |
|
| 5318 |
$explicit_success = 0; |
| 5264 |
while (<PIPE>) { |
5319 |
while (<PIPE>) { |
|
|
5320 |
if (/^successful$/) { |
| 5321 |
$explicit_success = 1; |
| 5322 |
last; |
| 5323 |
} |
| 5265 |
if (/^unsuccessful: exit code (\d+): (.*)/) { |
5324 |
if (/^unsuccessful: exit code (\d+): (.*)/) { |
| 5266 |
$retval = $1; |
5325 |
$retval = $1; |
| 5267 |
my $out = $2; |
5326 |
my $out = $2; |
|
Lines 5290-5300
sub test_bufferprog {
Link Here
|
| 5290 |
print $::msg "\n(debug) $pipecmd\n"; |
5349 |
print $::msg "\n(debug) $pipecmd\n"; |
| 5291 |
} |
5350 |
} |
| 5292 |
|
5351 |
|
| 5293 |
if ($retval == 0) { |
5352 |
if ($explicit_success) { |
| 5294 |
print $::msg "Ok\n"; |
5353 |
print $::msg "Ok\n"; |
| 5295 |
} else { |
5354 |
} else { |
|
|
5355 |
if ($retval == 0) { |
| 5356 |
push(@::errors, "Unanticipated problems encountered testing '$cfg::buffer' on host '$host'."); |
| 5357 |
} else { |
| 5296 |
print $::msg "Failed!\n"; |
5358 |
print $::msg "Failed!\n"; |
| 5297 |
} |
5359 |
} |
|
|
5360 |
} |
| 5298 |
unlink("$tmp_script"); |
5361 |
unlink("$tmp_script"); |
| 5299 |
|
5362 |
|
| 5300 |
return($retval); |
5363 |
return($retval); |
|
Lines 5396-5405
sub check_shell {
Link Here
|
| 5396 |
my $shell = $1; |
5459 |
my $shell = $1; |
| 5397 |
my $ver = $2; |
5460 |
my $ver = $2; |
| 5398 |
if ($shell eq 'bash') { |
5461 |
if ($shell eq 'bash') { |
| 5399 |
if ($ver =~ m/^2/) { |
5462 |
if ($ver =~ m/^1/) { |
| 5400 |
$::shelltype{$host} = 'bash2'; |
|
|
| 5401 |
} else { |
| 5402 |
$::shelltype{$host} = 'bash1'; |
5463 |
$::shelltype{$host} = 'bash1'; |
|
|
5464 |
} else { |
| 5465 |
$::shelltype{$host} = 'bash2'; |
| 5403 |
} |
5466 |
} |
| 5404 |
} else { |
5467 |
} else { |
| 5405 |
$::shelltype{$host} = $shell; |
5468 |
$::shelltype{$host} = $shell; |
|
Lines 5686-5688
sub spinner {
Link Here
|
| 5686 |
|
5749 |
|
| 5687 |
return($spinner[$index]); |
5750 |
return($spinner[$index]); |
| 5688 |
} |
5751 |
} |
|
|
5752 |
|
| 5753 |
|