1 |
diff -ruN e-smith-backup-2.4.0.old/root/etc/e-smith/events/actions/workstation-backup-dar e-smith-backup-2.4.0/root/etc/e-smith/events/actions/workstation-backup-dar |
2 |
--- e-smith-backup-2.4.0.old/root/etc/e-smith/events/actions/workstation-backup-dar 2014-04-19 10:05:05.000000000 -0700 |
3 |
+++ e-smith-backup-2.4.0/root/etc/e-smith/events/actions/workstation-backup-dar 2014-04-19 10:43:57.000000000 -0700 |
4 |
@@ -38,8 +38,8 @@ |
5 |
my $job = shift || 'DailyBackup'; |
6 |
my $confdb = esmith::ConfigDB->open; |
7 |
my $backupwk = $confdb->get('backupwk') or die "No backupwk db entry found\n"; |
8 |
-my $bkname = strftime '%Y%m%d%H%M%S', localtime; |
9 |
-my $dow = strftime '%w', localtime; |
10 |
+my $bkname = strftime '%Y%m%d%H%M%S', localtime; |
11 |
+my $dow = strftime '%w', localtime; |
12 |
my $ref = ""; |
13 |
|
14 |
my $id = $backupwk->prop('Id') || |
15 |
@@ -336,8 +336,8 @@ |
16 |
# it could become a common function later |
17 |
sub dmount |
18 |
{ |
19 |
- # mount dar unit according to dar-workstation configuration |
20 |
- # return nothing if mount successfull |
21 |
+ # mount dar unit according to dar-workstation configuration |
22 |
+ # return nothing if mount successfull |
23 |
|
24 |
my ($host,$share,$mountdir,$login,$password,$VFSType) = @_; |
25 |
|
26 |
@@ -394,7 +394,7 @@ |
27 |
eval {remove_tree("$tree")}; |
28 |
ldie("Error while deleting $tree : $@.\n") if $@; |
29 |
} |
30 |
- return; |
31 |
+ return; |
32 |
} |
33 |
|
34 |
sub createTree |
35 |
@@ -405,7 +405,7 @@ |
36 |
eval {make_path("$tree")}; |
37 |
ldie("Error while creating $tree : $@. Maybe insufficient rights directory.\n") if $@; |
38 |
} |
39 |
- return; |
40 |
+ return; |
41 |
} |
42 |
|
43 |
sub sendReport |
44 |
@@ -416,7 +416,7 @@ |
45 |
|| die "Cannot start mail program: $! $error\n"; |
46 |
print MAIL $text; |
47 |
close(MAIL); |
48 |
- return; |
49 |
+ return; |
50 |
} |
51 |
|
52 |
sub wol |
53 |
@@ -433,64 +433,64 @@ |
54 |
return $output; |
55 |
} |
56 |
|
57 |
-sub updateDarCatalog |
58 |
-{ |
59 |
- # update dar_manager catalog |
60 |
- my $mntbkdir = shift; |
61 |
- my $catalog = "$mntbkdir/dar-catalog"; |
62 |
- my %backupfiles = (); # hash of backup files found on the disk. |
63 |
- |
64 |
- unless ( -e $catalog) # Create an empty catalog if none found |
65 |
- { |
66 |
- system("/usr/bin/dar_manager", "-Q", "-C", "$catalog") == 0 |
67 |
- or ldie("Unable to create dar_manager catalog.\n"); |
68 |
- sleep 1; # sleep added to ensure the creation of a valid catalog |
69 |
- } |
70 |
- |
71 |
- # find available backups for the server |
72 |
- my $setbackuplist = sub {if($_ =~ /([\w|-]+)-(\d+)\..*\.dar/){$backupfiles{$2} = $File::Find::dir."/$1-$2";}}; |
73 |
+sub updateDarCatalog |
74 |
+{ |
75 |
+ # update dar_manager catalog |
76 |
+ my $mntbkdir = shift; |
77 |
+ my $catalog = "$mntbkdir/dar-catalog"; |
78 |
+ my %backupfiles = (); # hash of backup files found on the disk. |
79 |
+ |
80 |
+ unless ( -e $catalog) # Create an empty catalog if none found |
81 |
+ { |
82 |
+ system("/usr/bin/dar_manager", "-Q", "-C", "$catalog") == 0 |
83 |
+ or ldie("Unable to create dar_manager catalog.\n"); |
84 |
+ sleep 1; # sleep added to ensure the creation of a valid catalog |
85 |
+ } |
86 |
+ |
87 |
+ # find available backups for the server |
88 |
+ my $setbackuplist = sub {if($_ =~ /([\w|-]+)-(\d+)\..*\.dar/){$backupfiles{$2} = $File::Find::dir."/$1-$2";}}; |
89 |
find { wanted => \&$setbackuplist, untaint => 1 }, $mntbkdir ; |
90 |
- my @deletions; |
91 |
- |
92 |
- my $pid = open (DAR_LIST, "-|", "/usr/bin/dar_manager", "-Q", "-B", "$catalog", "-l") or ldie ("Cannot start : $!"); |
93 |
- my $catalogIndex; # Dar refers to each backup by an index |
94 |
- my $oldkey=0; # The key for %backupfiles is the timestamp |
95 |
- |
96 |
- while (<DAR_LIST>) |
97 |
- { |
98 |
- next unless ($_ =~ /(\d+).*\s[\w|-]+-(\d+)/); |
99 |
- ($catalogIndex, $oldkey) = ($1,$2); |
100 |
- |
101 |
- if (defined($backupfiles{$oldkey})) # found on disk and in catalog |
102 |
- { |
103 |
- delete $backupfiles{$oldkey}; # so that it will not be added in the next step. |
104 |
- } |
105 |
- else |
106 |
- { |
107 |
- push @deletions, $catalogIndex; # Will be deleted from the catalog |
108 |
- } |
109 |
- } |
110 |
- waitpid ($pid, 0); |
111 |
- my $err = WEXITSTATUS($?); |
112 |
- close (DAR_LIST); |
113 |
+ my @deletions; |
114 |
+ |
115 |
+ my $pid = open (DAR_LIST, "-|", "/usr/bin/dar_manager", "-Q", "-B", "$catalog", "-l") or ldie ("Cannot start : $!"); |
116 |
+ my $catalogIndex; # Dar refers to each backup by an index |
117 |
+ my $oldkey=0; # The key for %backupfiles is the timestamp |
118 |
+ |
119 |
+ while (<DAR_LIST>) |
120 |
+ { |
121 |
+ next unless ($_ =~ /(\d+).*\s[\w|-]+-(\d+)/); |
122 |
+ ($catalogIndex, $oldkey) = ($1,$2); |
123 |
+ |
124 |
+ if (defined($backupfiles{$oldkey})) # found on disk and in catalog |
125 |
+ { |
126 |
+ delete $backupfiles{$oldkey}; # so that it will not be added in the next step. |
127 |
+ } |
128 |
+ else |
129 |
+ { |
130 |
+ push @deletions, $catalogIndex; # Will be deleted from the catalog |
131 |
+ } |
132 |
+ } |
133 |
+ waitpid ($pid, 0); |
134 |
+ my $err = WEXITSTATUS($?); |
135 |
+ close (DAR_LIST); |
136 |
ldie ("Catalog error : $err") if $err; |
137 |
|
138 |
# Delete backups from the catalog that were missing on disk in descending order |
139 |
- while (my $catIndex = pop @deletions) |
140 |
- { |
141 |
- system("/usr/bin/dar_manager", "-Q", "-B", "$catalog", "-D", "$catIndex") == 0 |
142 |
- or ldie("Failed to delete set $catIndex from catalog. $!\n"); |
143 |
- sleep 1; # sleep added to ensure the creation of a valid catalog |
144 |
- } |
145 |
- |
146 |
- # Add backups that were missing from the catalog in chronological order |
147 |
- foreach my $key (sort keys %backupfiles) |
148 |
- { |
149 |
+ while (my $catIndex = pop @deletions) |
150 |
+ { |
151 |
+ system("/usr/bin/dar_manager", "-Q", "-B", "$catalog", "-D", "$catIndex") == 0 |
152 |
+ or ldie("Failed to delete set $catIndex from catalog. $!\n"); |
153 |
+ sleep 1; # sleep added to ensure the creation of a valid catalog |
154 |
+ } |
155 |
+ |
156 |
+ # Add backups that were missing from the catalog in chronological order |
157 |
+ foreach my $key (sort keys %backupfiles) |
158 |
+ { |
159 |
next unless ($key > $oldkey); # prevent adding old backups to the catalog |
160 |
- system("/usr/bin/dar_manager", "-Q", "-B", "$catalog", "-A", "$backupfiles{$key}") == 0 |
161 |
- or ldie("Failed to add set $backupfiles{$key} to catalog. $!\n"); |
162 |
- sleep 1; # sleep added to ensure the creation of a valid catalog |
163 |
+ system("/usr/bin/dar_manager", "-Q", "-B", "$catalog", "-A", "$backupfiles{$key}") == 0 |
164 |
+ or ldie("Failed to add set $backupfiles{$key} to catalog. $!\n"); |
165 |
+ sleep 1; # sleep added to ensure the creation of a valid catalog |
166 |
} |
167 |
- return; |
168 |
-} |
169 |
+ return; |
170 |
+} |
171 |
|