--- psinib.pl 2003/10/26 14:04:17 1.17 +++ psinib.pl 2003/10/27 19:07:32 1.19 @@ -199,14 +199,15 @@ my $share = shift; my $t = strftime $LOG_TIME_FMT, localtime; my $m = shift || '[no log entry]'; - my $l = shift || 1; + my $l = shift; + $l = 1 if (! defined $l); # default verbosity is 1 print STDERR $m,"\n" if ($verbose >= $l); print L "$t $share\t$m\n"; } # dump warn and dies into log -BEGIN { $SIG{'__WARN__'} = sub { xlog('WARN',$_[0]) ; warn $_[0] } } -BEGIN { $SIG{'__DIE__'} = sub { xlog('DIE',$_[0]) ; die $_[0] } } +BEGIN { $SIG{'__WARN__'} = sub { xlog('WARN',$_[0],1) ; warn $_[0] } } +BEGIN { $SIG{'__DIE__'} = sub { xlog('DIE',$_[0],0) ; die $_[0] } } # split share name to host, dir and currnet date dir @@ -248,8 +249,14 @@ if (-l $bl) { $real_bl=readlink($bl) || die "can't read link $bl: $!"; $real_bl="$BACKUP_DEST/$host/$dir/$real_bl" if (substr($real_bl,0,1) ne "/"); - } else { - xlog($share,"no old backup, trying to find last backup,"); + if (! -e $real_bl) { + xlog($share,"latest link $bl -> $real_bl not valid, removing it"); + unlink $bl || die "can't remove link $bl: $!"; + undef $real_bl; + } + } + if (! $real_bl) { + xlog($share,"no old backup, trying to find last backup"); if (opendir(BL_DIR, "$BACKUP_DEST/$host/$dir")) { my @bl_dirs = sort grep { !/^\./ && -d "$BACKUP_DEST/$host/$dir/$_" } readdir(BL_DIR); closedir(BL_DIR); @@ -382,7 +389,7 @@ my $pf = norm_dir($d,"smb:$share/"); # path full my $D = $smb->opendir($pf); if (! $D) { - xlog($share,"FATAL: $share [$pf]: $!"); + xlog($share,"FATAL: $share [$pf] as $param{username}/$param{workgroup}: $!",0); # remove failing dir delete $smb_dirs[$di]; return 0; # failed