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

Contents of /rpms/e-smith-backup/sme9/e-smith-backup-2.4.0-workstation-backup-dar-whitespace.patch

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


Revision 1.1 - (show annotations) (download)
Wed Dec 18 15:51:05 2013 UTC (10 years, 5 months ago) by wellsi
Branch: MAIN
CVS Tags: e-smith-backup-2_4_0-25_el6_sme, e-smith-backup-2_4_0-46_el6_sme, e-smith-backup-2_4_0-23_el6_sme, e-smith-backup-2_4_0-28_el6_sme, e-smith-backup-2_4_0-35_el6_sme, e-smith-backup-2_4_0-21_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-24_el6_sme, e-smith-backup-2_4_0-45_el6_sme, e-smith-backup-2_4_0-31_el6_sme, e-smith-backup-2_4_0-30_el6_sme, e-smith-backup-2_4_0-39_el6_sme, e-smith-backup-2_4_0-40_el6_sme, e-smith-backup-2_4_0-43_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-34_el6_sme, e-smith-backup-2_4_0-22_el6_sme, e-smith-backup-2_4_0-36_el6_sme, e-smith-backup-2_4_0-20_el6_sme, e-smith-backup-2_4_0-33_el6_sme, e-smith-backup-2_4_0-26_el6_sme, e-smith-backup-2_4_0-38_el6_sme, e-smith-backup-2_4_0-29_el6_sme, e-smith-backup-2_4_0-27_el6_sme, e-smith-backup-2_4_0-41_el6_sme, HEAD
* Wed Dec 18 2013 Ian Wells <esmith@wellsi.com> 2.4.0-20.sme
- Further refine the text in the Backup panel [SME: 7817]
- Workstation Backup, remove tabs and whitespace changes.

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 2013-12-12 21:37:57.000000000 -0800
3 +++ e-smith-backup-2.4.0/root/etc/e-smith/events/actions/workstation-backup-dar 2013-12-12 22:01:28.000000000 -0800
4 @@ -3,17 +3,17 @@
5 #----------------------------------------------------------------------
6 # copyright (C) 2006-2007 Jean-Paul Leclere <jean-paul@leclere.org>
7 # copyright (C) 2007 Charlie Brady <charlieb@e-smith.com>
8 -#
9 +#
10 # This program is free software; you can redistribute it and/or modify
11 # it under the terms of the GNU General Public License as published by
12 # the Free Software Foundation; either version 2 of the License, or
13 # (at your option) any later version.
14 -#
15 +#
16 # This program is distributed in the hope that it will be useful,
17 # but WITHOUT ANY WARRANTY; without even the implied warranty of
18 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 # GNU General Public License for more details.
20 -#
21 +#
22 # You should have received a copy of the GNU General Public License
23 # along with this program; if not, write to the Free Software
24 # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
25 @@ -98,18 +98,18 @@
26 # ping the SMB Host to see if it is awake
27
28 if (defined($smbhostmac) && (system("ping -c1 $smbhost > /dev/null") != 0)) {
29 - $report .= "$smbhost might be asleep, attempting to wake\n";
30 - system("ether-wake -i $ether $smbhostmac");
31 - $report .= "Waiting $smbhostdelay seconds...\n";
32 - sleep $smbhostdelay;
33 + $report .= "$smbhost might be asleep, attempting to wake\n";
34 + system("ether-wake -i $ether $smbhostmac");
35 + $report .= "Waiting $smbhostdelay seconds...\n";
36 + sleep $smbhostdelay;
37 }
38
39 # verify backup directory not already mounted
40 if (!&checkMount ($mntdir))
41 {
42 ldie("Seems backup directory is already mounted. " .
43 - "It should not happen and maybe there is a zombie process " .
44 - "you must kill, or another backup in progress. \n");
45 + "It should not happen and maybe there is a zombie process " .
46 + "you must kill, or another backup in progress. \n");
47 }
48
49 # create the directory mount point if it does not exist
50 @@ -133,14 +133,13 @@
51 }
52
53 # rotating backup indicators
54 -
55 -++$incnum;
56 +$incnum++;
57 $incnum = 0 if ($dow == $fullday && $incnum > $daysinset-7) ||
58 ($fullday == 7 && $incnum >= $daysinset);
59 if ($incnum == 0)
60 {
61 $setnum %= $setsmax;
62 - ++$setnum;
63 + $setnum++;
64 }
65
66 # if no set directory, make it
67 @@ -158,7 +157,6 @@
68 }
69 $report .= "Destination //$smbhost/$smbshare/$id/$setname\n";
70
71 -
72 if ( $incnum == 0 )
73 {
74 $bkname = "full-" . $bkname;
75 @@ -171,26 +169,26 @@
76 opendir(DIR, $setdirname) or ldie("Can't open dir $setdirname $!");
77 while (defined($file = readdir(DIR)))
78 {
79 - next if $file =~ /^\.\.?$/;
80 - if ($file =~ /dar$/)
81 - {
82 - $ref = $file;
83 - }
84 + next if $file =~ /^\.\.?$/;
85 + if ($file =~ /dar$/)
86 + {
87 + $ref = $file;
88 + }
89 }
90 closedir (DIR);
91 # if no reference do full backup
92 if ($ref eq "")
93 {
94 - $incnum = 0;
95 - $report .= "No existing reference backup, will make full backup \n";
96 - $bkname = "full-" . $bkname;
97 + $incnum = 0;
98 + $report .= "No existing reference backup, will make full backup \n";
99 + $bkname = "full-" . $bkname;
100 }
101 else
102 {
103 - # removing .dar extension
104 - $ref =~ s/\..*\.dar$//;
105 - $ref = "--ref|" . $setdirname . "/" . $ref; # | will be used to split this string in run_backup()
106 - $bkname = "inc-" . sprintf("%03d", $incnum) . "-". $bkname;
107 + # removing .dar extension
108 + $ref =~ s/\..*\.dar$//;
109 + $ref = "--ref|" . $setdirname . "/" . $ref; # | will be used to split this string in run_backup()
110 + $bkname = "inc-" . sprintf("%03d", $incnum) . "-". $bkname;
111 }
112 }
113
114 @@ -244,7 +242,7 @@
115 foreach (bsd_glob("$tmpdir/$id/$bkname*"))
116 {
117 ldie("Error while moving backup file $_ from temporary dir $tmpdir/$id to $setdirname : $!")
118 - unless move($_, $setdirname);
119 + unless move($_, $setdirname);
120 }
121 &removeTree ("$tmpdir/$id");
122 }
123 @@ -274,8 +272,8 @@
124 my $catalog = "$mntbkdir/dar-catalog";
125 unless ( -e $catalog) # Create an empty catalog if none found
126 {
127 - system("/usr/bin/dar_manager", "-Q", "-C", "$catalog") == 0
128 - or ldie("Unable to create dar_manager catalog.\n");
129 + system("/usr/bin/dar_manager", "-Q", "-C", "$catalog") == 0
130 + or ldie("Unable to create dar_manager catalog.\n");
131 }
132
133 # sleep added to ensure the creation of a valid catalog
134 @@ -285,7 +283,7 @@
135
136 find { wanted => \&$setbackuplist, untaint => 1 }, $mntbkdir ;
137
138 -# find backups in current catalog
139 +# find backups in current catalog
140
141 my $i = 0;
142 my @bknum;
143 @@ -295,10 +293,10 @@
144
145 while (<DAR_LIST>)
146 {
147 - next unless ($_ =~ /set/);
148 - chomp;
149 - ($bknum[$i], $setd[$i], $bkname[$i]) = split(' ', $_, 3);
150 - $i++;
151 + next unless ($_ =~ /set/);
152 + chomp;
153 + ($bknum[$i], $setd[$i], $bkname[$i]) = split(' ', $_, 3);
154 + $i++;
155 }
156 close (DAR_LIST);
157
158 @@ -307,51 +305,51 @@
159 my $j = $i;
160 while ($j)
161 {
162 - unless (-e "$setd[$j-1]/$bkname[$j-1]\.1\.dar")
163 - {
164 - my $del = $bknum[$j-1];
165 - if ($del =~ /^(.*)$/)
166 - {
167 - $del = $1;
168 - }
169 - system("/usr/bin/dar_manager", "-Q", "-B", "$catalog", "-D", "$del") == 0
170 - or ldie("Failed to delete set $del from catalog.\n");
171 - }
172 - $j--;
173 + unless (-e "$setd[$j-1]/$bkname[$j-1]\.1\.dar")
174 + {
175 + my $del = $bknum[$j-1];
176 + if ($del =~ /^(.*)$/)
177 + {
178 + $del = $1;
179 + }
180 + system("/usr/bin/dar_manager", "-Q", "-B", "$catalog", "-D", "$del") == 0
181 + or ldie("Failed to delete set $del from catalog.\n");
182 + }
183 + $j--;
184 }
185
186 # add to catalog new backups
187
188 foreach $key (sort keys %backupfiles)
189 {
190 - my $exists = 0;
191 - my $rf;
192 - foreach $rf (@bkname)
193 - {
194 - $exists = 1 if ($rf eq $backupfiles{$key}[1]);
195 - last if $exists;
196 - }
197 - do
198 - {
199 - my $add = "$mntbkdir/$backupfiles{$key}[0]/$backupfiles{$key}[1]";
200 - if ($add =~ /^(.*)$/)
201 - {
202 - $add = $1;
203 - }
204 - system("/usr/bin/dar_manager", "-Q", "-B", "$catalog", "-A", "$add") == 0
205 - or ldie("Failed to add set $add to catalog.\n");
206 - } unless $exists;
207 + my $exists = 0;
208 + my $rf;
209 + foreach $rf (@bkname)
210 + {
211 + $exists = 1 if ($rf eq $backupfiles{$key}[1]);
212 + last if $exists;
213 + }
214 + do
215 + {
216 + my $add = "$mntbkdir/$backupfiles{$key}[0]/$backupfiles{$key}[1]";
217 + if ($add =~ /^(.*)$/)
218 + {
219 + $add = $1;
220 + }
221 + system("/usr/bin/dar_manager", "-Q", "-B", "$catalog", "-A", "$add") == 0
222 + or ldie("Failed to add set $add to catalog.\n");
223 + } unless $exists;
224 }
225
226 # Check free disk space
227 my $df = qx(/bin/df -Ph \"$mntdir\");
228 if ($df =~ /(\S+)\s+(\S+)\s+(\S+)\s+(\d*%)/)
229 {
230 - $report .= "Destination disk usage $2, $4 full, $3 available\n";
231 + $report .= "Destination disk usage $2, $4 full, $3 available\n";
232 }
233 else
234 {
235 - $report .= "Destination disk space not available\n";
236 + $report .= "Destination disk space not available\n";
237 }
238
239 # unmount shared folder
240 @@ -382,10 +380,10 @@
241 $report .= $errmsg;
242 if (($mail eq 'yes') || ($mail eq 'error'))
243 {
244 - open (MAIL, "|/var/qmail/bin/qmail-inject")
245 - || die "Cannot start mail program: $!: message was $errmsg\n";
246 - print MAIL $report;
247 - close(MAIL);
248 + open (MAIL, "|/var/qmail/bin/qmail-inject")
249 + || die "Cannot start mail program: $!: message was $errmsg\n";
250 + print MAIL $report;
251 + close(MAIL);
252 }
253 system("/bin/umount", "$mntdir") if (!&checkMount ($mntdir));
254 die($errmsg);
255 @@ -394,68 +392,75 @@
256 sub start_dar_killer
257 {
258 my ($darpid, $gracetime) = @_;
259 - my $tick = $gracetime/10;
260 -
261 + my $tick = $gracetime/10;
262 +
263 my $killer = fork;
264 return $killer if $killer;
265
266 - POSIX::setsid;
267 - chdir '/';
268 - #fork && exit;
269 -
270 - # wait for timeout or backup termination
271 - while ($tick > 0) {
272 - sleep 10;
273 - $tick--;
274 - exit unless (kill(0, $darpid));
275 - }
276 -
277 - if (kill(0, $darpid)) {
278 - while (kill('QUIT', $darpid) != 1) {
279 - warn "Failed to stop $darpid dar process\n";
280 - }
281 - }
282 - warn "Partial backup stored on backup workstation.\n",
283 - "Session cleanly closed by timeout after $timeout seconds.\n",
284 - "Not an error, backup process will continue next night.\n";
285 + POSIX::setsid;
286 + chdir '/';
287 + #fork && exit;
288 +
289 + # wait for timeout or backup termination
290 + while ($tick > 0)
291 + {
292 + sleep 10;
293 + $tick--;
294 + exit unless (kill(0, $darpid));
295 + }
296
297 - exit;
298 + if (kill(0, $darpid))
299 + {
300 + while (kill('QUIT', $darpid) != 1)
301 + {
302 + warn "Failed to stop $darpid dar process\n";
303 + }
304 + }
305 + warn "Partial backup stored on backup workstation.\n",
306 + "Session cleanly closed by timeout after $timeout seconds.\n",
307 + "Not an error, backup process will continue next night.\n";
308 +
309 + exit;
310 }
311
312 sub run_backup
313 {
314 - my $dest = shift;
315 + my $dest = shift;
316 my $data = undef;
317 my $pid = undef;
318 my $killerpid = undef;
319
320 - eval {
321 - ($pid = open INPUT, "-|", "/usr/bin/dar", "-Q", "--create", "$dest", split(/\|/,$ref), "-B", "/etc/dar/$job.dcf") or ldie("cannot start : $!" );
322 + eval
323 + {
324 + ($pid = open INPUT, "-|", "/usr/bin/dar", "-Q", "--create", "$dest", split(/\|/,$ref), "-B", "/etc/dar/$job.dcf") or ldie("cannot start : $!" );
325
326 - if ($pid) {
327 - $killerpid = start_dar_killer($pid, $timeout); }
328 - $data = do { local($/); <INPUT> };
329 - };
330 - $report .= $data;
331 -
332 - if ($killerpid && kill(0, $killerpid)) {
333 - while (kill('TERM', $killerpid) != 1) {
334 - warn "Failed to kill $killerpid killer process\n";
335 - }
336 -
337 - waitpid($killerpid, 0);
338 - }
339 -
340 - waitpid($pid, 0);
341 - my $code = WEXITSTATUS($?);
342 - close(INPUT);
343 - return $code;
344 + if ($pid)
345 + {
346 + $killerpid = start_dar_killer($pid, $timeout);
347 + }
348 + $data = do { local($/); <INPUT> };
349 + };
350 + $report .= $data;
351 +
352 + if ($killerpid && kill(0, $killerpid))
353 + {
354 + while (kill('TERM', $killerpid) != 1)
355 + {
356 + warn "Failed to kill $killerpid killer process\n";
357 + }
358 + waitpid($killerpid, 0);
359 + }
360 +
361 + waitpid($pid, 0);
362 + my $code = WEXITSTATUS($?);
363 + close(INPUT);
364 + return $code;
365 }
366
367
368 sub checkMount
369 {
370 - # check if $mountdir is mounted
371 + # check if $mountdir is mounted
372 my $mountdir = shift;
373 return system("/bin/mountpoint", "-q", "$mountdir");
374 }
375 @@ -472,44 +477,45 @@
376
377 if ($VFSType eq 'cifs')
378 {
379 - return ( qx(/bin/mount -t cifs "//$host/$share" $mountdir -o credentials=/etc/dar/CIFScredentials,nounix 2>&1) );
380 + return ( qx(/bin/mount -t cifs "//$host/$share" $mountdir -o credentials=/etc/dar/CIFScredentials,nounix 2>&1) );
381 }
382 elsif ($VFSType eq 'nfs')
383 {
384 - return ( qx(/bin/mount -t nfs -o nolock "$host:/$share" $mountdir 2>&1) );
385 + return ( qx(/bin/mount -t nfs -o nolock "$host:/$share" $mountdir 2>&1) );
386 }
387 elsif ($VFSType eq 'usb')
388 {
389 - $_[2] = "/" . $share;
390 + $_[2] = "/" . $share;
391 my $device = "";
392 my $blkdev = "";
393 my $vollbl = "";
394 - foreach my $udi (qx(hal-find-by-property --key volume.fsusage --string filesystem)) {
395 - $udi =~ m/^(\S+)/;
396 - my $is_mounted = qx(hal-get-property --udi $1 --key volume.is_mounted);
397 -
398 - if ($is_mounted eq "false\n") {
399 - $blkdev = qx(hal-get-property --udi $1 --key block.device);
400 - if ($blkdev =~ m/^(\S+)/) {$blkdev = $1;}
401 - }
402 - if ($is_mounted eq "false\n") {
403 - $vollbl = qx(hal-get-property --udi $1 --key volume.label);
404 - $vollbl =~ m/^(\S+)/;
405 - if ($vollbl =~ /^\s/) {$vollbl = 'nolabel';}
406 - }
407 -
408 - chomp $vollbl;
409 - chomp $blkdev;
410 - $vollbl = "media/$vollbl";
411 - if ($vollbl eq $share) {
412 - $device = $blkdev;
413 - }
414 + foreach my $udi (qx(hal-find-by-property --key volume.fsusage --string filesystem))
415 + {
416 + $udi =~ m/^(\S+)/;
417 + my $is_mounted = qx(hal-get-property --udi $1 --key volume.is_mounted);
418 +
419 + if ($is_mounted eq "false\n")
420 + {
421 + $blkdev = qx(hal-get-property --udi $1 --key block.device);
422 + if ($blkdev =~ m/^(\S+)/) {$blkdev = $1;}
423 + }
424 + if ($is_mounted eq "false\n")
425 + {
426 + $vollbl = qx(hal-get-property --udi $1 --key volume.label);
427 + $vollbl =~ m/^(\S+)/;
428 + if ($vollbl =~ /^\s/) {$vollbl = 'nolabel';}
429 + }
430 +
431 + chomp $vollbl;
432 + chomp $blkdev;
433 + $vollbl = "media/$vollbl";
434 + if ($vollbl eq $share) {$device = $blkdev;}
435 }
436 return ( qx(/bin/mount $device "/$share" 2>&1) );
437 }
438 else
439 {
440 - return ("Mount of type $VFSType not supported.\n");
441 + return ("Mount of type $VFSType not supported.\n");
442 }
443 }
444
445 @@ -521,7 +527,7 @@
446 {
447 eval {remove_tree("$tree")};
448 ldie("Error while deleting $tree : $@.\n") if $@;
449 - }
450 + }
451 }
452
453 sub createTree
454 @@ -530,6 +536,6 @@
455 if (! -d "$tree")
456 {
457 eval {make_path("$tree")};
458 - ldie("Error while creating $tree : $@. Maybe insufficient rights directory.\n") if $@;
459 + ldie("Error while creating $tree : $@. Maybe insufficient rights directory.\n") if $@;
460 }
461 }

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