/[smeserver]/rpms/e-smith-backup/sme9/e-smith-backup-2.4.0-workstation-PerlCritic.patch
ViewVC logotype

Annotation of /rpms/e-smith-backup/sme9/e-smith-backup-2.4.0-workstation-PerlCritic.patch

Parent Directory Parent Directory | Revision Log Revision Log | View Revision Graph Revision Graph


Revision 1.1 - (hide annotations) (download)
Fri Mar 21 14:56:12 2014 UTC (10 years, 8 months ago) by wellsi
Branch: MAIN
CVS Tags: e-smith-backup-2_4_0-31_el6_sme, e-smith-backup-2_4_0-32_el6_sme, e-smith-backup-2_4_0-42_el6_sme, e-smith-backup-2_4_0-38_el6_sme, e-smith-backup-2_4_0-46_el6_sme, e-smith-backup-2_4_0-34_el6_sme, e-smith-backup-2_4_0-30_el6_sme, e-smith-backup-2_4_0-35_el6_sme, e-smith-backup-2_4_0-36_el6_sme, e-smith-backup-2_4_0-44_el6_sme, e-smith-backup-2_4_0-37_el6_sme, e-smith-backup-2_4_0-33_el6_sme, e-smith-backup-2_4_0-41_el6_sme, e-smith-backup-2_4_0-39_el6_sme, e-smith-backup-2_4_0-45_el6_sme, e-smith-backup-2_4_0-40_el6_sme, e-smith-backup-2_4_0-43_el6_sme, HEAD
* Fri Mar 11 2014 Ian Wells <esmith@wellsi.com> 2.4.0-30.sme
- Delete items from dar catalog in descending order [SME: 8129]
- Minor non-functional updates based on PerlCritic and review comments

1 wellsi 1.1 diff -ruN e-smith-backup-2.4.0.p30/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.p30/root/etc/e-smith/events/actions/workstation-backup-dar 2014-03-21 07:25:38.000000000 -0700
3     +++ e-smith-backup-2.4.0/root/etc/e-smith/events/actions/workstation-backup-dar 2014-03-21 07:46:55.000000000 -0700
4     @@ -75,10 +75,10 @@
5     $report .= "Backup of $id started at " .localtime() . "\n";
6    
7     # ping the SMB Host to see if it is awake
8     -$report .= &wol ($ether,$smbhost,$smbhostmac,$smbhostdelay);
9     +$report .= wol ($ether,$smbhost,$smbhostmac,$smbhostdelay);
10    
11     # verify backup directory not already mounted
12     -if (!&checkMount ($mntdir))
13     +if (!checkMount ($mntdir))
14     {
15     ldie("Seems backup directory is already mounted. " .
16     "It should not happen and maybe there is a zombie process " .
17     @@ -86,19 +86,19 @@
18     }
19    
20     # create the directory mount point if it does not exist
21     -&createTree ($mntdir);
22     +createTree ($mntdir);
23    
24     # mount the backup directory
25     -my $err = &dmount($smbhost,$smbshare,$mntdir,$login,$password,$VFSType);
26     -ldie("Error while mounting <//$smbhost/$smbshare>\n" . $err) if $err;
27     +my $err = dmount($smbhost,$smbshare,$mntdir,$login,$password,$VFSType);
28     +ldie("Error while mounting <//$smbhost/$smbshare>\n" . $err) if $err;
29    
30     # verify $mntdir is mounted
31     -if (&checkMount ($mntdir))
32     -{
33     +if (checkMount ($mntdir))
34     +{
35     # The mount should have suceeded, but sometimes it needs more time,
36     # so sleep and then check again.
37     sleep 5;
38     - if (&checkMount ($mntdir))
39     + if (checkMount ($mntdir))
40     {
41     ldie("Seems backup directory is not really mounted. It should not happen. \
42     Verify availability of your backup volume. Stopping the backup now.\n");
43     @@ -107,7 +107,7 @@
44    
45     # rotating backup indicators
46     $incnum++;
47     -$incnum = 0 if ($dow == $fullday && $incnum > $daysinset-7) ||
48     +$incnum = 0 if ($dow == $fullday && $incnum > $daysinset-7) ||
49     ($fullday == 7 && $incnum >= $daysinset);
50     if ($incnum == 0)
51     {
52     @@ -118,7 +118,7 @@
53     # if no set directory, make it
54     my $setname = "set$setnum";
55     my $setdirname = "$mntdir/$id/$setname";
56     -&createTree ($setdirname);
57     +createTree ($setdirname);
58    
59     $report .= "Destination //$smbhost/$smbshare/$id/$setname\n";
60    
61     @@ -190,11 +190,11 @@
62     my $destination = ($deleteearly ne 'true') ? "$mntdir/$id/$bkname" : "$setdirname/$bkname";
63    
64     # Perform the actual backup
65     -my $rc = run_backup($destination);
66     -
67     -if ($rc != 0 && $rc != 11)
68     -{
69     - ldie("Error while running dar: $rc");
70     +my $rc = run_backup($destination);
71     +
72     +if ($rc != 0 && $rc != 11)
73     +{
74     + ldie("Error while running dar: $rc");
75     }
76    
77     if ($deleteearly ne 'true') # Not DeleteEarly so move backup to $setdirname
78     @@ -214,7 +214,7 @@
79     }
80    
81     # update dar_manager catalog
82     -&updateDarCatalog ("$mntdir/$id");
83     +updateDarCatalog ("$mntdir/$id");
84    
85     # Check free disk space
86     my $df = qx(/bin/df -Ph \"$mntdir\");
87     @@ -237,11 +237,11 @@
88     $report .= "Backup successfully terminated at ".localtime()."\n";
89    
90     # Send the Workstation Backup report
91     -if ($mail eq 'yes') {&sendReport ($report);}
92     +if ($mail eq 'yes') {sendReport ($report);}
93    
94     exit (0);
95    
96     -sub ldie
97     +sub ldie
98     {
99     my $errmsg = shift;
100     $report =~ s/Report:/Failed:/;
101     @@ -249,9 +249,9 @@
102     $report .= $errmsg;
103     if (($mail eq 'yes') || ($mail eq 'error'))
104     {
105     - &sendReport ($report,$errmsg);
106     + sendReport ($report,$errmsg);
107     }
108     - system("/bin/umount", "$mntdir") if (!&checkMount ($mntdir));
109     + system("/bin/umount", "$mntdir") if (!checkMount ($mntdir));
110     die($errmsg);
111     }
112    
113     @@ -268,21 +268,21 @@
114     #fork && exit;
115    
116     # wait for timeout or backup termination
117     - while ($tick > 0)
118     + while ($tick > 0)
119     {
120     sleep 10;
121     $tick--;
122     exit unless (kill(0, $darpid));
123     }
124    
125     - if (kill(0, $darpid))
126     + if (kill(0, $darpid))
127     {
128     - while (kill('QUIT', $darpid) != 1)
129     + while (kill('QUIT', $darpid) != 1)
130     {
131     warn "Failed to stop $darpid dar process\n";
132     }
133     }
134     - warn "Partial backup stored on backup workstation.\n",
135     + warn "Partial backup stored on backup workstation.\n",
136     "Session cleanly closed by timeout after $timeout seconds.\n",
137     "Not an error, backup process will continue next night.\n";
138    
139     @@ -296,11 +296,11 @@
140     my $pid = undef;
141     my $killerpid = undef;
142    
143     - eval
144     + eval
145     {
146     ($pid = open INPUT, "-|", "/usr/bin/dar", "-Q", "--create", "$dest", split(/\|/,$ref), "-B", "/etc/dar/$job.dcf") or ldie("cannot start : $!" );
147    
148     - if ($pid)
149     + if ($pid)
150     {
151     $killerpid = start_dar_killer($pid, $timeout);
152     }
153     @@ -308,9 +308,9 @@
154     };
155     $report .= $data;
156    
157     - if ($killerpid && kill(0, $killerpid))
158     + if ($killerpid && kill(0, $killerpid))
159     {
160     - while (kill('TERM', $killerpid) != 1)
161     + while (kill('TERM', $killerpid) != 1)
162     {
163     warn "Failed to kill $killerpid killer process\n";
164     }
165     @@ -324,7 +324,7 @@
166     }
167    
168    
169     -sub checkMount
170     +sub checkMount
171     {
172     # check if $mountdir is mounted
173     my $mountdir = shift;
174     @@ -334,13 +334,13 @@
175    
176     # dmount is copied from /etc/e-smith/web/functions/backup
177     # it could become a common function later
178     -sub dmount()
179     +sub dmount
180     {
181     - # mount dar unit according to dar-workstation configuration
182     - # return nothing if mount successfull
183     + # mount dar unit according to dar-workstation configuration
184     + # return nothing if mount successfull
185    
186     my ($host,$share,$mountdir,$login,$password,$VFSType) = @_;
187     -
188     +
189     if ($VFSType eq 'cifs')
190     {
191     return ( qx(/bin/mount -t cifs "//$host/$share" $mountdir -o credentials=/etc/dar/CIFScredentials,nounix 2>&1) );
192     @@ -355,23 +355,23 @@
193     my $device = "";
194     my $blkdev = "";
195     my $vollbl = "";
196     - foreach my $udi (qx(hal-find-by-property --key volume.fsusage --string filesystem))
197     + foreach my $udi (qx(hal-find-by-property --key volume.fsusage --string filesystem))
198     {
199     $udi =~ m/^(\S+)/;
200     my $is_mounted = qx(hal-get-property --udi $1 --key volume.is_mounted);
201    
202     - if ($is_mounted eq "false\n")
203     + if ($is_mounted eq "false\n")
204     {
205     $blkdev = qx(hal-get-property --udi $1 --key block.device);
206     if ($blkdev =~ m/^(\S+)/) {$blkdev = $1;}
207     }
208     - if ($is_mounted eq "false\n")
209     + if ($is_mounted eq "false\n")
210     {
211     $vollbl = qx(hal-get-property --udi $1 --key volume.label);
212     $vollbl =~ m/^(\S+)/;
213     if ($vollbl =~ /^\s/) {$vollbl = 'nolabel';}
214     }
215     -
216     +
217     chomp $vollbl;
218     chomp $blkdev;
219     $vollbl = "media/$vollbl";
220     @@ -394,6 +394,7 @@
221     eval {remove_tree("$tree")};
222     ldie("Error while deleting $tree : $@.\n") if $@;
223     }
224     + return;
225     }
226    
227     sub createTree
228     @@ -404,6 +405,7 @@
229     eval {make_path("$tree")};
230     ldie("Error while creating $tree : $@. Maybe insufficient rights directory.\n") if $@;
231     }
232     + return;
233     }
234    
235     sub sendReport
236     @@ -414,13 +416,14 @@
237     || die "Cannot start mail program: $! $error\n";
238     print MAIL $text;
239     close(MAIL);
240     + return;
241     }
242    
243     sub wol
244     {
245     my ($ether,$host,$mac,$delay) = @_;
246     my $output="";
247     -
248     +
249     if (defined($mac) && (system("ping -c1 $host > /dev/null") != 0)) {
250     $output .= "$host might be asleep, attempting to wake\n";
251     system("ether-wake -i $ether $mac");
252     @@ -430,7 +433,7 @@
253     return $output;
254     }
255    
256     -sub updateDarCatalog ()
257     +sub updateDarCatalog
258     {
259     # update dar_manager catalog
260     my $mntbkdir = shift;
261     @@ -438,7 +441,7 @@
262     my %backupfiles = (); # hash of backup files found on the disk.
263    
264     unless ( -e $catalog) # Create an empty catalog if none found
265     - {
266     + {
267     system("/usr/bin/dar_manager", "-Q", "-C", "$catalog") == 0
268     or ldie("Unable to create dar_manager catalog.\n");
269     sleep 1; # sleep added to ensure the creation of a valid catalog
270     @@ -487,6 +490,7 @@
271     system("/usr/bin/dar_manager", "-Q", "-B", "$catalog", "-A", "$backupfiles{$key}") == 0
272     or ldie("Failed to add set $backupfiles{$key} to catalog. $!\n");
273     sleep 1; # sleep added to ensure the creation of a valid catalog
274     - }
275     + }
276     + return;
277     }
278    

admin@koozali.org
ViewVC Help
Powered by ViewVC 1.2.1 RSS 2.0 feed