1 |
wellsi |
1.1 |
diff -ruN e-smith-backup-2.4.0.p29/root/etc/e-smith/events/actions/workstation-backup-dar e-smith-backup-2.4.0.p30/root/etc/e-smith/events/actions/workstation-backup-dar |
2 |
|
|
--- e-smith-backup-2.4.0.p29/root/etc/e-smith/events/actions/workstation-backup-dar 2014-03-20 22:04:42.000000000 -0700 |
3 |
|
|
+++ e-smith-backup-2.4.0.p30/root/etc/e-smith/events/actions/workstation-backup-dar 2014-03-21 07:25:38.000000000 -0700 |
4 |
|
|
@@ -441,14 +441,13 @@ |
5 |
|
|
{ |
6 |
|
|
system("/usr/bin/dar_manager", "-Q", "-C", "$catalog") == 0 |
7 |
|
|
or ldie("Unable to create dar_manager catalog.\n"); |
8 |
|
|
+ sleep 1; # sleep added to ensure the creation of a valid catalog |
9 |
|
|
} |
10 |
|
|
|
11 |
|
|
- # sleep added to ensure the creation of a valid catalog |
12 |
|
|
- sleep 1; |
13 |
|
|
- |
14 |
|
|
# find available backups for the server |
15 |
|
|
my $setbackuplist = sub {if($_ =~ /([\w|-]+)-(\d+)\..*\.dar/){$backupfiles{$2} = $File::Find::dir."/$1-$2";}}; |
16 |
|
|
- find { wanted => \&$setbackuplist, untaint => 1 }, $mntbkdir ; |
17 |
|
|
+ find { wanted => \&$setbackuplist, untaint => 1 }, $mntbkdir ; |
18 |
|
|
+ my @deletions; |
19 |
|
|
|
20 |
|
|
my $pid = open (DAR_LIST, "-|", "/usr/bin/dar_manager", "-Q", "-B", "$catalog", "-l") or ldie ("Cannot start : $!"); |
21 |
|
|
my $catalogIndex; # Dar refers to each backup by an index |
22 |
|
|
@@ -456,9 +455,7 @@ |
23 |
|
|
|
24 |
|
|
while (<DAR_LIST>) |
25 |
|
|
{ |
26 |
|
|
- next unless ($_ =~ /set/); |
27 |
|
|
- chomp; |
28 |
|
|
- $_ =~ /(\d+).*\s[\w|-]+-(\d+)/; |
29 |
|
|
+ next unless ($_ =~ /(\d+).*\s[\w|-]+-(\d+)/); |
30 |
|
|
($catalogIndex, $oldkey) = ($1,$2); |
31 |
|
|
|
32 |
|
|
if (defined($backupfiles{$oldkey})) # found on disk and in catalog |
33 |
|
|
@@ -467,21 +464,29 @@ |
34 |
|
|
} |
35 |
|
|
else |
36 |
|
|
{ |
37 |
|
|
- system("/usr/bin/dar_manager", "-Q", "-B", "$catalog", "-D", "$catalogIndex") == 0 |
38 |
|
|
- or ldie("Failed to delete set $catalogIndex from catalog.\n"); |
39 |
|
|
+ push @deletions, $catalogIndex; # Will be deleted from the catalog |
40 |
|
|
} |
41 |
|
|
} |
42 |
|
|
waitpid ($pid, 0); |
43 |
|
|
my $err = WEXITSTATUS($?); |
44 |
|
|
close (DAR_LIST); |
45 |
|
|
- ldie ("Catalog error : $err") if $err; |
46 |
|
|
+ ldie ("Catalog error : $err") if $err; |
47 |
|
|
+ |
48 |
|
|
+ # Delete backups from the catalog that were missing on disk in descending order |
49 |
|
|
+ while (my $catIndex = pop @deletions) |
50 |
|
|
+ { |
51 |
|
|
+ system("/usr/bin/dar_manager", "-Q", "-B", "$catalog", "-D", "$catIndex") == 0 |
52 |
|
|
+ or ldie("Failed to delete set $catIndex from catalog. $!\n"); |
53 |
|
|
+ sleep 1; # sleep added to ensure the creation of a valid catalog |
54 |
|
|
+ } |
55 |
|
|
|
56 |
|
|
- # Now add backups that were missing from the catalog in chronological order |
57 |
|
|
+ # Add backups that were missing from the catalog in chronological order |
58 |
|
|
foreach my $key (sort keys %backupfiles) |
59 |
|
|
{ |
60 |
|
|
next unless ($key > $oldkey); # prevent adding old backups to the catalog |
61 |
|
|
system("/usr/bin/dar_manager", "-Q", "-B", "$catalog", "-A", "$backupfiles{$key}") == 0 |
62 |
|
|
- or ldie("Failed to add set $backupfiles{$key} to catalog.\n"); |
63 |
|
|
+ or ldie("Failed to add set $backupfiles{$key} to catalog. $!\n"); |
64 |
|
|
+ sleep 1; # sleep added to ensure the creation of a valid catalog |
65 |
|
|
} |
66 |
|
|
} |
67 |
|
|
|