81 |
next if !/^\s*smbmount\s/; |
next if !/^\s*smbmount\s/; |
82 |
my (undef,$share,undef,$opt) = split(/\s+/,$_,4); |
my (undef,$share,undef,$opt) = split(/\s+/,$_,4); |
83 |
|
|
84 |
my ($user,$passwd,$workgroup); |
my ($user,$passwd,$workgroup,$ip); |
85 |
|
|
86 |
foreach (split(/,/,$opt)) { |
foreach (split(/,/,$opt)) { |
87 |
my ($n,$v) = split(/=/,$_,2); |
my ($n,$v) = split(/=/,$_,2); |
97 |
} |
} |
98 |
} elsif ($n =~ m#workgroup#i) { |
} elsif ($n =~ m#workgroup#i) { |
99 |
$workgroup = $v; |
$workgroup = $v; |
100 |
|
} elsif ($n =~ m#ip#i) { |
101 |
|
$ip = $v; |
102 |
} |
} |
103 |
} |
} |
104 |
|
|
109 |
my $bl = "$BACKUP_DEST/$host/$dir/latest"; # latest backup |
my $bl = "$BACKUP_DEST/$host/$dir/latest"; # latest backup |
110 |
my $bc = "$BACKUP_DEST/$host/$dir/$date_dir"; # current one |
my $bc = "$BACKUP_DEST/$host/$dir/$date_dir"; # current one |
111 |
my $real_bl; |
my $real_bl; |
112 |
if (-e $bl) { |
if (-l $bl) { |
113 |
$real_bl=readlink($bl) || die "can't read link $bl: $!"; |
$real_bl=readlink($bl) || die "can't read link $bl: $!"; |
114 |
$real_bl="$BACKUP_DEST/$host/$dir/$real_bl" if (substr($real_bl,0,1) ne "/"); |
$real_bl="$BACKUP_DEST/$host/$dir/$real_bl" if (substr($real_bl,0,1) ne "/"); |
115 |
if (-e $bc && $real_bl eq $bc) { |
if (-l $bc && $real_bl eq $bc) { |
116 |
print "$share allready backuped...\n"; |
print "$share allready backuped...\n"; |
117 |
$backup_ok++; |
$backup_ok++; |
118 |
next; |
next; |
123 |
|
|
124 |
print "working on $share\n"; |
print "working on $share\n"; |
125 |
|
|
126 |
|
# try to nmblookup IP |
127 |
my $ip = get_ip($share); |
$ip = get_ip($share) if (! $ip); |
128 |
|
|
129 |
if ($ip) { |
if ($ip) { |
130 |
xlog($share,"IP is $ip"); |
xlog($share,"IP is $ip"); |
206 |
my $bc = "$BACKUP_DEST/$host/$dir/$date_dir"; |
my $bc = "$BACKUP_DEST/$host/$dir/$date_dir"; |
207 |
|
|
208 |
my $real_bl; |
my $real_bl; |
209 |
if (-e $bl) { |
if (-l $bl) { |
210 |
$real_bl=readlink($bl) || die "can't read link $bl: $!"; |
$real_bl=readlink($bl) || die "can't read link $bl: $!"; |
211 |
$real_bl="$BACKUP_DEST/$host/$dir/$real_bl" if (substr($real_bl,0,1) ne "/"); |
$real_bl="$BACKUP_DEST/$host/$dir/$real_bl" if (substr($real_bl,0,1) ne "/"); |
212 |
} else { |
} else { |
227 |
} |
} |
228 |
} |
} |
229 |
|
|
230 |
if (-e $bc && $real_bl && $real_bl eq $bc) { |
if (-l $bc && $real_bl && $real_bl eq $bc) { |
231 |
print "$share allready backuped...\n"; |
print "$share allready backuped...\n"; |
232 |
return; |
return; |
233 |
} |
} |
287 |
push @ignore,norm_dir("$d/$_"); |
push @ignore,norm_dir("$d/$_"); |
288 |
} |
} |
289 |
close(I); |
close(I); |
290 |
print STDERR "ignore: ",join("|",@ignore),"\n"; |
#print STDERR "ignore: ",join("|",@ignore),"\n"; |
291 |
link "$real_bl/$d/.backupignore","$bc/$d/.backupignore" || |
link "$real_bl/$d/.backupignore","$bc/$d/.backupignore" || |
292 |
warn "can't copy $real_bl/$d/.backupignore to current backup dir: $!\n"; |
warn "can't copy $real_bl/$d/.backupignore to current backup dir: $!\n"; |
293 |
} |
} |
337 |
|
|
338 |
$di = 0; |
$di = 0; |
339 |
while ($di <= $#smb_dirs) { |
while ($di <= $#smb_dirs) { |
340 |
my $d=$smb_dirs[$di++]; |
my $d=$smb_dirs[$di]; |
341 |
my $pf = norm_dir($d,"smb:$share/"); # path full |
my $pf = norm_dir($d,"smb:$share/"); # path full |
342 |
my $D = $smb->opendir($pf) || warn "smb->opendir($pf): $!\n"; |
my $D = $smb->opendir($pf); |
343 |
|
if (! $D) { |
344 |
|
xlog($share,"FATAL: $share: $!"); |
345 |
|
# remove failing dir |
346 |
|
delete $smb_dirs[$di]; |
347 |
|
next; |
348 |
|
} |
349 |
|
$di++; |
350 |
|
|
351 |
my @clutter = $smb->readdir_struct($D); |
my @clutter = $smb->readdir_struct($D); |
352 |
foreach my $item (@clutter) { |
foreach my $item (@clutter) { |
514 |
} |
} |
515 |
print $md5 $file_md5{$f}," $file\n"; |
print $md5 $file_md5{$f}," $file\n"; |
516 |
} |
} |
517 |
close($md5); |
close($md5) if ($md5); |
518 |
|
|
519 |
# create leatest link |
# create leatest link |
520 |
#print "ln -s $bc $real_bl\n"; |
#print "ln -s $bc $real_bl\n"; |
521 |
if (-e $bl) { |
if (-l $bl) { |
522 |
unlink $bl || warn "can't remove old latest symlink $bl: $!\n"; |
unlink $bl || warn "can't remove old latest symlink $bl: $!\n"; |
523 |
} |
} |
524 |
symlink $bc,$bl || warn "can't create latest symlink $bl -> $bc: $!\n"; |
symlink $bc,$bl || warn "can't create latest symlink $bl -> $bc: $!\n"; |
525 |
|
|
526 |
# FIX: sanity check -- remove for speedup |
# FIX: sanity check -- remove for speedup |
527 |
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); |
528 |
|
|
529 |
xlog($share,"backup completed..."); |
xlog($share,"backup completed..."); |
530 |
} |
} |