--- psinib.pl 2003/03/04 21:08:43 1.8 +++ psinib.pl 2003/10/12 15:58:28 1.11 @@ -81,7 +81,7 @@ next if !/^\s*smbmount\s/; my (undef,$share,undef,$opt) = split(/\s+/,$_,4); - my ($user,$passwd,$workgroup); + my ($user,$passwd,$workgroup,$ip); foreach (split(/,/,$opt)) { my ($n,$v) = split(/=/,$_,2); @@ -97,6 +97,8 @@ } } elsif ($n =~ m#workgroup#i) { $workgroup = $v; + } elsif ($n =~ m#ip#i) { + $ip = $v; } } @@ -107,10 +109,10 @@ my $bl = "$BACKUP_DEST/$host/$dir/latest"; # latest backup my $bc = "$BACKUP_DEST/$host/$dir/$date_dir"; # current one my $real_bl; - if (-e $bl) { + 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 "/"); - if (-e $bc && $real_bl eq $bc) { + if (-l $bc && $real_bl eq $bc) { print "$share allready backuped...\n"; $backup_ok++; next; @@ -121,8 +123,8 @@ print "working on $share\n"; - - my $ip = get_ip($share); + # try to nmblookup IP + $ip = get_ip($share) if (! $ip); if ($ip) { xlog($share,"IP is $ip"); @@ -204,7 +206,7 @@ my $bc = "$BACKUP_DEST/$host/$dir/$date_dir"; my $real_bl; - if (-e $bl) { + 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 { @@ -225,7 +227,7 @@ } } - if (-e $bc && $real_bl && $real_bl eq $bc) { + if (-l $bc && $real_bl && $real_bl eq $bc) { print "$share allready backuped...\n"; return; } @@ -285,7 +287,7 @@ push @ignore,norm_dir("$d/$_"); } close(I); -print STDERR "ignore: ",join("|",@ignore),"\n"; +#print STDERR "ignore: ",join("|",@ignore),"\n"; link "$real_bl/$d/.backupignore","$bc/$d/.backupignore" || warn "can't copy $real_bl/$d/.backupignore to current backup dir: $!\n"; } @@ -335,9 +337,16 @@ $di = 0; while ($di <= $#smb_dirs) { - my $d=$smb_dirs[$di++]; + my $d=$smb_dirs[$di]; my $pf = norm_dir($d,"smb:$share/"); # path full - my $D = $smb->opendir($pf) || warn "smb->opendir($pf): $!\n"; + my $D = $smb->opendir($pf); + if (! $D) { + xlog($share,"FATAL: $share: $!"); + # remove failing dir + delete $smb_dirs[$di]; + next; + } + $di++; my @clutter = $smb->readdir_struct($D); foreach my $item (@clutter) { @@ -505,17 +514,17 @@ } print $md5 $file_md5{$f}," $file\n"; } - close($md5); + close($md5) if ($md5); # create leatest link #print "ln -s $bc $real_bl\n"; - if (-e $bl) { + if (-l $bl) { unlink $bl || warn "can't remove old latest symlink $bl: $!\n"; } symlink $bc,$bl || warn "can't create latest symlink $bl -> $bc: $!\n"; # FIX: sanity check -- remove for speedup - xlog($share,"failed to create latest symlink...") if (readlink($bl) ne $bc || ! -e $bl); + xlog($share,"failed to create latest symlink $bl -> $bc...") if (readlink($bl) ne $bc || ! -l $bl); xlog($share,"backup completed..."); }