107 |
my $bl = "$BACKUP_DEST/$host/$dir/latest"; # latest backup |
my $bl = "$BACKUP_DEST/$host/$dir/latest"; # latest backup |
108 |
my $bc = "$BACKUP_DEST/$host/$dir/$date_dir"; # current one |
my $bc = "$BACKUP_DEST/$host/$dir/$date_dir"; # current one |
109 |
my $real_bl; |
my $real_bl; |
110 |
if (-e $bl) { |
if (-l $bl) { |
111 |
$real_bl=readlink($bl) || die "can't read link $bl: $!"; |
$real_bl=readlink($bl) || die "can't read link $bl: $!"; |
112 |
$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 "/"); |
113 |
if (-e $bc && $real_bl eq $bc) { |
if (-l $bc && $real_bl eq $bc) { |
114 |
print "$share allready backuped...\n"; |
print "$share allready backuped...\n"; |
115 |
$backup_ok++; |
$backup_ok++; |
116 |
next; |
next; |
204 |
my $bc = "$BACKUP_DEST/$host/$dir/$date_dir"; |
my $bc = "$BACKUP_DEST/$host/$dir/$date_dir"; |
205 |
|
|
206 |
my $real_bl; |
my $real_bl; |
207 |
if (-e $bl) { |
if (-l $bl) { |
208 |
$real_bl=readlink($bl) || die "can't read link $bl: $!"; |
$real_bl=readlink($bl) || die "can't read link $bl: $!"; |
209 |
$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 "/"); |
210 |
} else { |
} else { |
225 |
} |
} |
226 |
} |
} |
227 |
|
|
228 |
if (-e $bc && $real_bl && $real_bl eq $bc) { |
if (-l $bc && $real_bl && $real_bl eq $bc) { |
229 |
print "$share allready backuped...\n"; |
print "$share allready backuped...\n"; |
230 |
return; |
return; |
231 |
} |
} |
285 |
push @ignore,norm_dir("$d/$_"); |
push @ignore,norm_dir("$d/$_"); |
286 |
} |
} |
287 |
close(I); |
close(I); |
288 |
print STDERR "ignore: ",join("|",@ignore),"\n"; |
#print STDERR "ignore: ",join("|",@ignore),"\n"; |
289 |
link "$real_bl/$d/.backupignore","$bc/$d/.backupignore" || |
link "$real_bl/$d/.backupignore","$bc/$d/.backupignore" || |
290 |
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"; |
291 |
} |
} |
335 |
|
|
336 |
$di = 0; |
$di = 0; |
337 |
while ($di <= $#smb_dirs) { |
while ($di <= $#smb_dirs) { |
338 |
my $d=$smb_dirs[$di++]; |
my $d=$smb_dirs[$di]; |
339 |
my $pf = norm_dir($d,"smb:$share/"); # path full |
my $pf = norm_dir($d,"smb:$share/"); # path full |
340 |
my $D = $smb->opendir($pf) || warn "smb->opendir($pf): $!\n"; |
my $D = $smb->opendir($pf); |
341 |
|
if (! $D) { |
342 |
|
xlog($share,"FATAL: $share: $!"); |
343 |
|
# remove failing dir |
344 |
|
delete $smb_dirs[$di]; |
345 |
|
next; |
346 |
|
} |
347 |
|
$di++; |
348 |
|
|
349 |
my @clutter = $smb->readdir_struct($D); |
my @clutter = $smb->readdir_struct($D); |
350 |
foreach my $item (@clutter) { |
foreach my $item (@clutter) { |
503 |
foreach my $f (sort { $file_md5{$a} cmp $file_md5{$b} } keys %file_md5) { |
foreach my $f (sort { $file_md5{$a} cmp $file_md5{$b} } keys %file_md5) { |
504 |
my $dir = dirname($f); |
my $dir = dirname($f); |
505 |
my $file = basename($f); |
my $file = basename($f); |
506 |
#print "$f -- $dir / $file<--\n"; |
print "$f -- $dir / $file<--\n"; |
507 |
if ($dir ne $last_dir) { |
if ($dir ne $last_dir) { |
508 |
close($md5) if ($md5); |
close($md5) if ($md5); |
509 |
open($md5, ">> $bc/$dir/.md5sum") || warn "can't create $bc/$dir/.md5sum: $!"; |
open($md5, ">> $bc/$dir/.md5sum") || warn "can't create $bc/$dir/.md5sum: $!"; |
516 |
|
|
517 |
# create leatest link |
# create leatest link |
518 |
#print "ln -s $bc $real_bl\n"; |
#print "ln -s $bc $real_bl\n"; |
519 |
if (-e $bl) { |
if (-l $bl) { |
520 |
unlink $bl || warn "can't remove old latest symlink $bl: $!\n"; |
unlink $bl || warn "can't remove old latest symlink $bl: $!\n"; |
521 |
} |
} |
522 |
symlink $bc,$bl || warn "can't create latest symlink $bl -> $bc: $!\n"; |
symlink $bc,$bl || warn "can't create latest symlink $bl -> $bc: $!\n"; |
523 |
|
|
524 |
# FIX: sanity check -- remove for speedup |
# FIX: sanity check -- remove for speedup |
525 |
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); |
526 |
|
|
527 |
xlog($share,"backup completed..."); |
xlog($share,"backup completed..."); |
528 |
} |
} |