/[smeserver]/rpms/e-smith-backup/sme7/e-smith-backup-1.15.0-reformat.patch
ViewVC logotype

Annotation of /rpms/e-smith-backup/sme7/e-smith-backup-1.15.0-reformat.patch

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


Revision 1.1 - (hide annotations) (download)
Sat Sep 8 00:55:20 2007 UTC (17 years, 2 months ago) by slords
Branch: MAIN
CVS Tags: e-smith-backup-1_15_0-17_el4_sme, e-smith-backup-1_15_0-14_el4_sme, e-smith-backup-1_15_0-11_el4_sme, e-smith-backup-1_15_0-16_el4_sme, e-smith-backup-1_15_0-13_el4_sme, e-smith-backup-1_15_0-10_el4_sme, e-smith-backup-1_15_0-20_el4_sme, e-smith-backup-1_15_0-8_el4_sme, e-smith-backup-1_15_0-19_el4_sme, e-smith-backup-1_15_0-03_el4_sme, e-smith-backup-1_15_0-18_el4_sme, e-smith-backup-1_15_0-15_el4_sme, e-smith-backup-1_15_0-05_el4_sme, e-smith-backup-1_15_0-7_el4_sme, e-smith-backup-1_15_0-06_el4_sme, e-smith-backup-1_15_0-9_el4_sme, e-smith-backup-1_15_0-12_el4_sme, e-smith-backup-1_15_0-22_el4_sme, e-smith-backup-1_15_0-21_el4_sme, e-smith-backup-1_15_0-04_el4_sme
Update packages

1 slords 1.1 diff -Nur -x '*.orig' -x '*.rej' e-smith-backup-1.15.0/root/etc/e-smith/events/actions/workstation-backup-dar mezzanine_patched_e-smith-backup-1.15.0/root/etc/e-smith/events/actions/workstation-backup-dar
2     --- e-smith-backup-1.15.0/root/etc/e-smith/events/actions/workstation-backup-dar 2007-09-07 14:38:19.000000000 -0400
3     +++ mezzanine_patched_e-smith-backup-1.15.0/root/etc/e-smith/events/actions/workstation-backup-dar 2007-09-05 17:03:55.000000000 -0400
4     @@ -2,6 +2,7 @@
5    
6     #----------------------------------------------------------------------
7     # copyright (C) 2006 Jean-Paul Leclere <jean-paul@leclere.org>
8     +# copyright (C) 2007 Charlie Brady <charlieb@e-smith.com>
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     @@ -38,10 +39,16 @@
13    
14     my $tm = localtime(time);
15     my $bkname = $tm->year+1900;
16     - if (($tm->mon) < 9) {$bkname .= ("0".($tm->mon+1))} else {$bkname .= ($tm->mon+1)}
17     - if (($tm->mday) < 10) {$bkname .= ("0".$tm->mday)} else {$bkname .= $tm->mday}
18     +
19     +$bkname .= "0" if ($tm->mon < 9);
20     +$bkname .= $tm->mon + 1;
21     +
22     +$bkname .= "0" if ($tm->mday < 10);
23     +$bkname .= $tm->mday;
24     +
25     my $dow = $tm->wday;
26     -my $id = $backupwk->prop('Id') || $confdb->get('SystemName')->value . "." . $confdb->get('DomainName')->value;
27     +my $id = $backupwk->prop('Id') ||
28     + $confdb->get('SystemName')->value . "." . $confdb->get('DomainName')->value;
29     my $err;
30     my $ref = "";
31     my $mntdone = 0;
32     @@ -77,42 +84,58 @@
33    
34     # verify backup directory not already mounted
35    
36     -if ( $VFSType ne 'usb' ) {
37     +if ( $VFSType eq 'usb' )
38     +{
39     + $mntdir = "/$smbshare";
40     +}
41     +else
42     +{
43     open FD, '/proc/mounts';
44     - while (<FD>) {
45     + while (<FD>)
46     + {
47     next unless /$smbhost(.*)\/$smbshare/;
48     next unless /$mntdir/;
49     $err++
50     - }
51     + }
52     close FD;
53     - if ($err) {
54     - ldie("Seems backup directory is already mounted. It should not happen \
55     -and maybe there is a zombie process you must kill, or another backup in progress. \n")
56     - }
57     - if ($VFSType eq 'cifs'){
58     - $err = qx(/bin/mount -t cifs $smbhost:$smbshare $mntdir -o user=$login,pass=$password);
59     - if ($err) {ldie("Error while mounting $smbhost:$smbshare : \n" . $err)};
60     - }
61     - elsif ($VFSType eq 'smbfs'){
62     - $err = qx(/bin/mount -t smbfs //$smbhost/$smbshare $mntdir -o username=$login,password=$password,dmask=777,fmask=777,ip=$smbhost 2>&1);
63     - if ($err) {ldie("Error while mounting //$smbhost/$smbshare : \n" . $err)};
64     - }
65     - elsif ($VFSType eq 'nfs'){
66     + if ($err)
67     + {
68     + ldie("Seems backup directory is already mounted. " .
69     + "It should not happen and maybe there is a zombie process " .
70     + "you must kill, or another backup in progress. \n");
71     + }
72     + if ($VFSType eq 'cifs')
73     + {
74     + $err = qx(/bin/mount -t cifs $smbhost:$smbshare $mntdir -o user=$login,pass=$password 2>&1);
75     + ldie("Error while mounting $smbhost:$smbshare : \n" . $err) if $err;
76     + }
77     + elsif ($VFSType eq 'smbfs')
78     + {
79     + $err =
80     + qx(/bin/mount -t smbfs //$smbhost/$smbshare $mntdir
81     + -o username=$login,password=$password,dmask=777,fmask=777,ip=$smbhost 2>&1);
82     + ldie("Error while mounting //$smbhost/$smbshare : \n" . $err) if $err;
83     + }
84     + elsif ($VFSType eq 'nfs')
85     + {
86     $err = qx(/bin/mount -t nfs -o nolock $smbhost:/$smbshare $mntdir 2>&1);
87     - if ($err) {ldie("Error while mounting $smbhost:/$smbshare : \n" . $err)};
88     - }
89     - else {ldie("Error while mounting $smbhost/$smbshare : $VFSType not supported.\n")}
90     -
91     - $mntdone = 1;
92     + ldie("Error while mounting $smbhost:/$smbshare : \n" . $err) if $err;
93     + }
94     + else
95     + {
96     + ldie("Error while mounting $smbhost/$smbshare : $VFSType not supported.\n");
97     }
98     -else { $mntdir = "/".$smbshare }
99     + $mntdone = 1;
100     +}
101    
102     -if (-d "$tmpdir/$id") {
103     +if (-d "$tmpdir/$id")
104     +{
105     eval {rmtree("$tmpdir/$id")};
106     - if ($@) {ldie("Error while deleting $tmpdir/$id : $@.\n")}
107     - }
108     + ldie("Error while deleting $tmpdir/$id : $@.\n") if $@;
109     +}
110     eval {mkpath("$tmpdir/$id")};
111     -if ($@) {ldie("Error while creating $tmpdir/$id : $@. Maybe insufficient rights on backup directory.\n")}
112     +ldie("Error while creating $tmpdir/$id : $@. Maybe insufficient rights on backup directory.\n")
113     + if $@;
114    
115     # we know right backup directory is in line and we can write on it.
116     $report .= "Backup temp directory $tmpdir/$id is mounted and is writable \n";
117     @@ -121,63 +144,69 @@
118    
119     ++$incnum;
120     $incnum %= $daysinset;
121     -if ( $incnum == 0 ) {
122     +if ($incnum == 0)
123     +{
124     ++$setnum;
125     $setnum %= $setsmax;
126     - }
127     +}
128    
129     $report .= "Using set number $setnum of $setsmax\n";
130     -if ($incnum == 0) {
131     - $report .= "Attempt to full backup \n";
132     - }
133     -else {
134     - $report .= "Attempt to incremental backup number $incnum of $daysinset\n";
135     - }
136     +$report .= "Attempt to " .
137     + ($incnum == 0) ?
138     + "full backup \n" :
139     + "incremental backup number $incnum of $daysinset\n";
140    
141     # if no set directory, make it
142     -
143     my $setname = "set" . $setnum;
144     my $setdirname = $mntdir . "/$id/" . $setname;
145    
146     -unless ( -d $setdirname ) {
147     +unless ( -d $setdirname )
148     +{
149     eval {mkpath($setdirname)};
150     - if ($@) {ldie("Can't create $setdirname : $@.\n")}
151     + ldie("Can't create $setdirname : $@.\n") if $@;
152     $report .= "Backup directory $id/$setname created \n";
153     - }
154     +}
155    
156     -# if $incnum <> 0 backup should be incremental
157     -# we find correct reference backup for incremental
158     -
159     -if ( $incnum != 0 ) {
160     +if ( $incnum == 0 )
161     +{
162     + $bkname = "full-" . $bkname;
163     +}
164     +else
165     +{
166     + # if $incnum <> 0 backup should be incremental
167     + # we find correct reference backup for incremental
168     my $file;
169     opendir(DIR, $setdirname) or ldie("Can't open dir $setdirname $!");
170     - while (defined($file = readdir(DIR))) {
171     + while (defined($file = readdir(DIR)))
172     + {
173     next if $file =~ /^\.\.?$/;
174     - if ( $file =~ /dar$/) {
175     + if ($file =~ /dar$/)
176     + {
177     $ref = $file;
178     - }
179     }
180     + }
181     closedir (DIR);
182     # if no reference do full backup
183     - if ($ref eq "") {
184     + if ($ref eq "")
185     + {
186     $incnum = 0;
187     $report .= "No existing reference backup, will make full backup \n";
188     $bkname = "full-" . $bkname;
189     - }
190     - else { # removing .dar extension
191     + }
192     + else
193     + {
194     + # removing .dar extension
195     $ref =~ s/\..*\.dar$//;
196     $ref = "--ref " . $setdirname . "/" . $ref;
197     $bkname = "inc-" . sprintf("%03d", $incnum) . "-". $bkname;
198     - }
199     - }
200     -else {
201     - $bkname = "full-" . $bkname;
202     }
203     +}
204    
205     -unless ( ( $incnum != 0 ) || ( $fullday == 7 ) || ( $dow == $fullday ) ) {
206     +unless ( ( $incnum != 0 ) || ( $fullday == 7 ) || ( $dow == $fullday ) )
207     +{
208     my $delay = ($fullday - $dow) % 7;
209     ldie("Not a permitted day for full backup. Aborting...\nNext full backup in $delay days.\n");
210     - }
211     +}
212    
213     $report .= "Backup base file name is $bkname \n";
214     $report .= "Making backup on temporary dir... \n";
215     @@ -185,9 +214,10 @@
216     # calculate real timeout if we timeout incrementals only.
217     # timeout of 88500 is a security for aborting backup within 24h
218    
219     -if ( ($ref eq "") && ($inconly eq "yes")) {
220     +if ( ($ref eq "") && ($inconly eq "yes"))
221     +{
222     $timeout = 88500;
223     - }
224     +}
225     $report .= "using a backup session timeout of : $timeout seconds\n";
226    
227     # expanding backup configuration file template
228     @@ -198,40 +228,52 @@
229    
230     # launching dar backup
231    
232     -$err = system("/usr/bin/timeout -s TERM $timeout /usr/bin/dar -c $tmpdir/$id/$bkname $ref -B /etc/dar/$job.dcf");
233     +$err = system("/usr/bin/timeout",
234     + "-s",
235     + "TERM",
236     + "$timeout",
237     + "/usr/bin/dar",
238     + "-c",
239     + "$tmpdir/$id/$bkname",
240     + "$ref",
241     + "-B",
242     + "/etc/dar/$job.dcf");
243    
244     if ($err == 0)
245     {
246     -$report .= "Backup completed successfully on temporary dir \n";
247     + $report .= "Backup completed successfully on temporary dir \n";
248     }
249     elsif ($err == 15)
250     {
251     -$report .= "Partial backup stored on temp dir.\n"
252     - . " Session closed by timeout after $timeout seconds.\n"
253     - . "Not an error, backup process will continue next night.\n";
254     + $report .= "Partial backup stored on temp dir.\n"
255     + . " Session closed by timeout after $timeout seconds.\n"
256     + . "Not an error, backup process will continue next night.\n";
257     }
258     else
259     {
260     -$err = $err >> 8;
261     -ldie("Dar error during backup : $err \n");
262     + $err = $err >> 8;
263     + ldie("Dar error during backup : $err \n");
264     }
265    
266     -if ($incnum == 0) {
267     +if ($incnum == 0)
268     +{
269     $report .= "Rotating backups in a new set $setdirname. \n";
270     eval {rmtree($setdirname)};
271     - if ($@) {ldie("Error while deleting $setdirname : $@.\n")}
272     + ldie("Error while deleting $setdirname : $@.\n") if $@;
273     eval {mkpath("$setdirname")};
274     - if ($@) {ldie("Error while creating $setdirname : $@.\n")}
275     - }
276     + ldie("Error while creating $setdirname : $@.\n") if $@;
277     +}
278     +
279     $report .= "Moving backup files to target directory $setdirname \n";
280     -foreach (<$tmpdir/$id/$bkname*>) {
281     - unless ( move($_, $setdirname) )
282     - {ldie("Error while moving backup file $_ from temporary dir $tmpdir/$id to $setdirname : $!")};
283     - }
284    
285     -# unmount shared folder
286     +foreach (<$tmpdir/$id/$bkname*>)
287     +{
288     + ldie("Error while moving backup file $_ from temporary dir $tmpdir/$id to $setdirname : $!")
289     + unless move($_, $setdirname);
290     +}
291    
292     -if ( $VFSType ne 'usb' ) {system("/bin/umount -f $mntdir")}
293     +# unmount shared folder
294     +system("/bin/umount -f $mntdir") unless ($VFSType ne 'usb');
295    
296     # time now to update backup configuration
297    
298     @@ -242,26 +284,28 @@
299     $tim = ctime();
300     $report .= "Backup successfully terminated at : $tim \n";
301    
302     -if ($mail eq 'yes') {
303     +if ($mail eq 'yes')
304     +{
305     open (MAIL, "|/var/qmail/bin/qmail-inject -a admin")
306     || die "Cannot start mail program: $!\n";
307     print MAIL $report;
308     close(MAIL);
309     - }
310     +}
311    
312     exit (0);
313    
314     sub ldie
315     {
316     -my $errmsg = shift;
317     -$report .= "*** No backup allowed or error during backup ***\n";
318     -$report .= $errmsg;
319     -if (($mail eq 'yes') || ($mail eq 'error')) {
320     - open (MAIL, "|/var/qmail/bin/qmail-inject -a admin")
321     - || die "Cannot start mail program: $!\n";
322     - print MAIL $report;
323     - close(MAIL);
324     + my $errmsg = shift;
325     + $report .= "*** No backup allowed or error during backup ***\n";
326     + $report .= $errmsg;
327     + if (($mail eq 'yes') || ($mail eq 'error'))
328     + {
329     + open (MAIL, "|/var/qmail/bin/qmail-inject -a admin")
330     + || die "Cannot start mail program: $!: message was $errmsg\n";
331     + print MAIL $report;
332     + close(MAIL);
333     }
334     -if (($mntdone) && ($VFSType ne 'usb')) {system("/bin/umount $mntdir")};
335     -die($errmsg);
336     + system("/bin/umount $mntdir") if $mntdone;
337     + die($errmsg);
338     }
339     diff -Nur -x '*.orig' -x '*.rej' e-smith-backup-1.15.0/root/etc/e-smith/web/functions/backup mezzanine_patched_e-smith-backup-1.15.0/root/etc/e-smith/web/functions/backup
340     --- e-smith-backup-1.15.0/root/etc/e-smith/web/functions/backup 2007-09-07 14:38:19.000000000 -0400
341     +++ mezzanine_patched_e-smith-backup-1.15.0/root/etc/e-smith/web/functions/backup 2007-09-07 14:37:54.000000000 -0400
342     @@ -2192,47 +2192,53 @@
343     my $mntdir = $backupwkrec->prop('MountDir') || '/mnt/smb';
344     my $mounted;
345     my $key;
346     - my $id = $backupwkrec->prop('Id') || $conf->get('SystemName')->value . "." . $conf->get('DomainName')->value;
347     + my $id = $backupwkrec->prop('Id') ||
348     + $conf->get('SystemName')->value . "." . $conf->get('DomainName')->value;
349     my $err;
350     my $VFSType = $backupwkrec->prop('VFSType') || 'smbfs';
351    
352     # Mounting backup shared folder
353    
354     - if ( $err = dmount($smbhost,$smbshare,$mntdir,$login,$password,$VFSType) )
355     - {
356     + if ($err = dmount($smbhost,$smbshare,$mntdir,$login,$password,$VFSType))
357     + {
358     esmith::cgi::genResult(
359     $q, $fm->localise('ERR_MOUNTING_SMBSHARE') . "\n" . $err
360     );
361     return;
362     - }
363     - elsif ( $VFSType ne 'usb' ) {$mounted = 1}
364     + }
365     + elsif ( $VFSType ne 'usb' )
366     + {
367     + $mounted = 1;
368     + }
369    
370     # Test if backup subdirectory for our server
371    
372     my $mntbkdir = $mntdir . "/$id";
373     - unless ( -d $mntbkdir)
374     - {
375     - if ($mounted) {
376     + unless (-d $mntbkdir)
377     + {
378     + if ($mounted)
379     + {
380     system("/bin/umount $mntdir") == 0
381     or die($fm->localise('ERR_WHILE_UNMOUNTING'),"\n");
382     - }
383     - esmith::cgi::genResult(
384     - $q, $fm->localise('ERR_NO_HOST_DIR'.$id)
385     - );
386     - return;
387     }
388     + esmith::cgi::genResult($q, $fm->localise('ERR_NO_HOST_DIR'.$id));
389     + return;
390     + }
391    
392     my $backupkey = $q->param ('backupset');
393     - if ($backupkey =~ /^(.*)$/) {
394     + if ($backupkey =~ /^(.*)$/)
395     + {
396     $backupkey = $1;
397     - }
398     - else {
399     - if ($mounted) {
400     + }
401     + else
402     + {
403     + if ($mounted)
404     + {
405     system("/bin/umount $mntdir") == 0
406     or die($fm->localise('ERR_WHILE_UNMOUNTING'),"\n");
407     - }
408     - die('Unsecure data : ' . $backupkey);
409     }
410     + die('Unsecure data : ' . $backupkey);
411     + }
412    
413     if (open(RD, "-|"))
414     {
415     @@ -2300,14 +2306,16 @@
416     my $mounted;
417     my %backupfiles = ();
418     my $key;
419     - my $id = $rec->prop('Id') || $conf->get('SystemName')->value . "." . $conf->get('DomainName')->value;
420     + my $id = $rec->prop('Id') ||
421     + $conf->get('SystemName')->value . "." . $conf->get('DomainName')->value;
422     my $VFSType = $rec->prop('VFSType') || 'smbfs';
423     my $smbhost = $rec->prop('SmbHost');
424     my $smbshare = $rec->prop('SmbShare');
425     my $err;
426    
427     my $setbackupflist = sub {
428     - if ( $_ =~ /\.dar/ ) {
429     + if ( $_ =~ /\.dar/ )
430     + {
431     my $dir = $File::Find::dir;
432     my $backupref;
433     $dir =~ s/$mntbkdir\///;
434     @@ -2320,38 +2328,38 @@
435     };
436    
437     # Mounting backup shared folder
438     -
439     unless (-d $mntdir)
440     {
441     - mkdir -p $mntdir;
442     + mkdir -p $mntdir;
443     }
444    
445     my $login = $rec->prop('Login') || 'backup';
446     my $password = $rec->prop('Password') || 'backup';
447    
448     - if ( $err = dmount($smbhost,$smbshare,$mntdir,$login,$password,$VFSType) )
449     - {
450     - esmith::cgi::genResult(
451     - $q, $fm->localise('ERR_MOUNTING_SMBSHARE') . "\n" . $err
452     - );
453     + if ($err = dmount($smbhost,$smbshare,$mntdir,$login,$password,$VFSType))
454     + {
455     + esmith::cgi::genResult($q,
456     + $fm->localise('ERR_MOUNTING_SMBSHARE') . "\n" . $err);
457     return;
458     - }
459     - elsif ( $VFSType ne 'usb' ) {$mounted = 1}
460     + }
461     + elsif ($VFSType ne 'usb')
462     + {
463     + $mounted = 1;
464     + }
465    
466     # Test if backup subdirectory for our server
467    
468     $mntbkdir = $mntdir . "/$id";
469     unless ( -d $mntbkdir)
470     - {
471     - if ($mounted) {
472     + {
473     + if ($mounted)
474     + {
475     system("/bin/umount $mntdir") == 0
476     or die($fm->localise('ERR_WHILE_UNMOUNTING'),"\n");
477     - }
478     - esmith::cgi::genResult(
479     - $q, $fm->localise('ERR_NO_HOST_DIR'.$id)
480     - );
481     - return;
482     }
483     + esmith::cgi::genResult($q, $fm->localise('ERR_NO_HOST_DIR'.$id));
484     + return;
485     + }
486    
487     # Finding existing backups
488    
489     @@ -2361,18 +2369,21 @@
490     my @blabels;
491     my $backups = 0;
492    
493     - foreach $key (sort keys %backupfiles) {
494     + foreach $key (sort keys %backupfiles)
495     + {
496     my $labkey = $mntbkdir . '/' . $backupfiles{$key}[0] . '/' . $backupfiles{$key}[1];
497     $blabels{$labkey} = $backupfiles{$key}[1] . ' (' . $backupfiles{$key}[0] . ')';
498     $backups = push @blabels, $labkey;
499     - }
500     + }
501    
502     - if ($mounted) {
503     + if ($mounted)
504     + {
505     system("/bin/umount $mntdir") == 0
506     or die($fm->localise('ERR_WHILE_UNMOUNTING'),"\n");
507     - }
508     + }
509    
510     - if ( $backups == 0 ) {
511     + if ( $backups == 0 )
512     + {
513     esmith::cgi::genResult(
514     $q, $fm->localise('NO_BACKUPS_TO_RESTORE'));
515     return;
516     @@ -2430,7 +2441,8 @@
517     my @restorefiles;
518    
519     my $backupsetlist = sub {
520     - if ( $_ =~ /\.dar/ ) {
521     + if ( $_ =~ /\.dar/ )
522     + {
523     my $backupref = $File::Find::name;
524     $backupref =~ s/\.[0-9]+\.dar//;
525     $_ =~ s/\..*\.dar//;
526     @@ -2464,7 +2476,8 @@
527     my $backupwkrec = $conf->get('backupwk');
528     my $login = $backupwkrec->prop('Login');
529     my $password = $backupwkrec->prop('Password');
530     - my $id = $backupwkrec->prop('Id') || $conf->get('SystemName')->value . "." . $conf->get('DomainName')->value;
531     + my $id = $backupwkrec->prop('Id')
532     + || $conf->get('SystemName')->value . "." . $conf->get('DomainName')->value;
533     my $mntdir = $backupwkrec->prop('MountDir') || '/mnt/smb';
534     my $mounted;
535     my $VFSType = $backupwkrec->prop('VFSType') || 'smbfs';
536     @@ -2472,8 +2485,8 @@
537     my $smbshare = $backupwkrec->prop('SmbShare');
538     my $err;
539    
540     - if ( $err = dmount($smbhost,$smbshare,$mntdir,$login,$password,$VFSType) )
541     - {
542     + if ($err = dmount($smbhost,$smbshare,$mntdir,$login,$password,$VFSType))
543     + {
544     esmith::cgi::genHeaderNonCacheable(
545     $q,
546     undef, $fm->localise('RESTORE_CANNOT_PROCEED')
547     @@ -2482,33 +2495,38 @@
548     $q, $fm->localise('ERR_MOUNTING_SMBSHARE') . "\n" . $err
549     );
550     return;
551     - }
552     - elsif ( $VFSType ne 'usb' ) {$mounted = 1}
553     + }
554     + elsif ($VFSType ne 'usb')
555     + {
556     + $mounted = 1;
557     + }
558    
559     # Test if backup subdirectory for our server
560    
561     my $mntbkdir = $mntdir . "/$id";
562     unless ( -d $mntbkdir)
563     - {
564     - if ($mounted) {
565     + {
566     + if ($mounted)
567     + {
568     system("/bin/umount $mntdir") == 0
569     or die($fm->localise('ERR_WHILE_UNMOUNTING'),"\n");
570     - }
571     + }
572     esmith::cgi::genResult(
573     $q, $fm->localise('ERR_NO_HOST_DIR'.$id)
574     );
575     return;
576     - }
577     + }
578    
579     # finding list of available backups
580    
581     find { wanted => \&$backupsetlist, untaint => 1 }, $set ;
582    
583     my $key;
584     - foreach $key (sort keys %backupsetfiles) {
585     + foreach $key (sort keys %backupsetfiles)
586     + {
587     push @restorefiles, $backupsetfiles{$key};
588     last if ( $backupsetfiles{$key} eq $restoreref );
589     - }
590     + }
591    
592     # backup is online, restoring now
593    
594     @@ -2622,24 +2640,29 @@
595     $| = 1;
596    
597     my $file;
598     - foreach $file (@restorefiles) {
599     - if ($file =~ /^(.*)$/) {
600     + foreach $file (@restorefiles)
601     + {
602     + if ($file =~ /^(.*)$/)
603     + {
604     $file = $1;
605     - }
606     - else {
607     - if ($mounted) {
608     + }
609     + else
610     + {
611     + if ($mounted)
612     + {
613     system("/bin/umount $mntdir") == 0
614     or die($fm->localise('ERR_WHILE_UNMOUNTING'),"\n");
615     - }
616     - die('Unsecure data : ' . $file);
617     }
618     - system ("/usr/bin/dar -x $file --verbose --noconf --no-warn=all");
619     + die('Unsecure data : ' . $file);
620     }
621     + system ("/usr/bin/dar -x $file --verbose --noconf --no-warn=all");
622     + }
623    
624     - if ($mounted) {
625     + if ($mounted)
626     + {
627     system("/bin/umount $mntdir") == 0
628     or die($fm->localise('ERR_WHILE_UNMOUNTING'),"\n");
629     - }
630     + }
631    
632     exit(0);
633     }
634     @@ -2665,7 +2688,8 @@
635     my $mntbkdir;
636     my $mounted;
637     my $key;
638     - my $id = $rec->prop('Id') || $conf->get('SystemName')->value . '.' . $conf->get('DomainName')->value;
639     + my $id = $rec->prop('Id') ||
640     + $conf->get('SystemName')->value . '.' . $conf->get('DomainName')->value;
641     my %blabels = ();
642     my @blabels;
643     my $backups = 0;
644     @@ -2676,7 +2700,8 @@
645     my $err;
646    
647     my $setbackuplist = sub {
648     - if ( $_ =~ /\.dar/ ) {
649     + if ( $_ =~ /\.dar/ )
650     + {
651     my $dir = $File::Find::dir;
652     my $backupref;
653     $dir =~ s/$mntbkdir\///;
654     @@ -2692,42 +2717,46 @@
655    
656     unless (-d $mntdir)
657     {
658     - mkdir -p $mntdir;
659     + mkdir -p $mntdir;
660     }
661    
662     my $login = $rec->prop('Login') || 'backup';
663     my $password = $rec->prop('Password') || 'backup';
664    
665     - if ( $err = dmount($smbhost,$smbshare,$mntdir,$login,$password,$VFSType) )
666     - {
667     + if ($err = dmount($smbhost,$smbshare,$mntdir,$login,$password,$VFSType))
668     + {
669     esmith::cgi::genResult(
670     $q, $fm->localise('ERR_MOUNTING_SMBSHARE') . "\n" . $err
671     );
672     return;
673     - }
674     - elsif ( $VFSType ne 'usb' ) {$mounted = 1}
675     + }
676     + elsif ($VFSType ne 'usb')
677     + {
678     + $mounted = 1;
679     + }
680    
681     # Test if backup subdirectory for our server
682    
683     $mntbkdir = $mntdir . '/' . $id;
684     unless ( -d $mntbkdir)
685     - {
686     - if ($mounted) {
687     + {
688     + if ($mounted)
689     + {
690     system("/bin/umount $mntdir") == 0
691     or die($fm->localise('ERR_WHILE_UNMOUNTING'),"\n");
692     - }
693     + }
694     esmith::cgi::genResult(
695     $q, $fm->localise('ERR_NO_HOST_DIR'.$id)
696     );
697     return;
698     - }
699     + }
700    
701     my $catalog = "$mntbkdir/dar-catalog";
702     unless ( -e $catalog)
703     - {
704     + {
705     system("/usr/bin/dar_manager -C $catalog") == 0
706     or die($fm->localise('ERR_DAR_CATALOG'),"\n");
707     - }
708     + }
709    
710     # find available backups for the server
711    
712     @@ -2740,59 +2769,68 @@
713     my @setd;
714     my @bkname;
715     open(DAR_LIST, "/usr/bin/dar_manager -B $catalog -l |");
716     - while (<DAR_LIST>) {
717     + while (<DAR_LIST>)
718     + {
719     next unless ($_ =~ /set/);
720     chomp;
721     ($bknum[$i], $setd[$i], $bkname[$i]) = split(' ', $_, 3);
722     $i++;
723     - }
724     + }
725     close (DAR_LIST);
726    
727     # delete from catalog old removed backups
728    
729     my $j = $i;
730     - while ($j) {
731     - unless (-e "$setd[$j-1]/$bkname[$j-1]\.1\.dar") {
732     + while ($j)
733     + {
734     + unless (-e "$setd[$j-1]/$bkname[$j-1]\.1\.dar")
735     + {
736     my $del = $bknum[$j-1];
737     - if ($del =~ /^(.*)$/) {
738     + if ($del =~ /^(.*)$/)
739     + {
740     $del = $1;
741     - }
742     - system("/usr/bin/dar_manager -B $catalog -D $del 1>&2") == 0
743     + }
744     + system("/usr/bin/dar_manager -B $catalog -D $del 1>&2") == 0
745     or die($fm->localise('ERR_DAR_CATALOG'),"\n");
746     }
747     $j--;
748     - }
749     + }
750    
751     # add to catalog new backups
752    
753     - foreach $key (sort keys %backupfiles) {
754     + foreach $key (sort keys %backupfiles)
755     + {
756     my $exists = 0;
757     my $rf;
758     - foreach $rf (@bkname) {
759     + foreach $rf (@bkname)
760     + {
761     $exists = 1 if ($rf eq $backupfiles{$key}[1]);
762     last if $exists;
763     - }
764     - do {
765     + }
766     + do
767     + {
768     my $add = "$mntbkdir/$backupfiles{$key}[0]/$backupfiles{$key}[1]";
769     - if ($add =~ /^(.*)$/) {
770     + if ($add =~ /^(.*)$/)
771     + {
772     $add = $1;
773     - }
774     + }
775     system("/usr/bin/dar_manager -B $catalog -A $add") == 0
776     or die($fm->localise('ERR_DAR_CATALOG'),"\n");
777     - } unless $exists;
778     - }
779     + } unless $exists;
780     + }
781    
782     # update backups list from current catalog
783    
784     open(DAR_LIST, "/usr/bin/dar_manager -B $catalog -l |") ;
785    
786     $i = 0;
787     - while (<DAR_LIST>) {
788     + while (<DAR_LIST>)
789     + {
790     next unless m/set/;
791     chomp;
792     ($bknum[$i], $setd[$i], $bkname[$i]) = split(' ', $_, 3);
793     $i++;
794     - }
795     + }
796     close (DAR_LIST);
797    
798     # set drop down list of backups
799     @@ -2800,11 +2838,12 @@
800     push @blabels, "0";
801     $blabels{"0"} = $fm->localise('ALL_BACKUPS');
802     $j = 0;
803     - while ($j < $i) {
804     + while ($j < $i)
805     + {
806     push @blabels, $bknum[$j];
807     $blabels{$bknum[$j]} = $bkname[$j];
808     $j++
809     - }
810     + }
811    
812     print $q->p ($fm->localise('WORKSTN_SEL_REST_DESC') . " $smbhost/$smbshare/$id");
813    
814     @@ -2857,10 +2896,11 @@
815    
816     esmith::cgi::genFooter ($q);
817    
818     - if ($mounted) {
819     + if ($mounted)
820     + {
821     system("/bin/umount $mntdir") == 0
822     or die($fm->localise('ERR_WHILE_UNMOUNTING'),"\n");
823     - }
824     + }
825     }
826    
827     sub performWorkstnSelRestore
828     @@ -2869,10 +2909,13 @@
829    
830     my $rgfilter;
831     my $filterexp = $q->param ('filterexp');
832     - if ($filterexp =~ /^(.*)$/) {
833     + if ($filterexp =~ /^(.*)$/)
834     + {
835     $filterexp = $1;
836     $rgfilter = qr/$filterexp/;
837     - } else {
838     + }
839     + else
840     + {
841     $filterexp = "";
842     }
843     my $seldatebf;
844     @@ -2889,45 +2932,52 @@
845     my $mntbkdir;
846     my $mounted;
847     my $key;
848     - my $id = $backupwkrec->prop('Id') || $conf->get('SystemName')->value . "." . $conf->get('DomainName')->value;
849     + my $id = $backupwkrec->prop('Id') ||
850     + $conf->get('SystemName')->value . "." . $conf->get('DomainName')->value;
851     my @flabels;
852     my %flabels = ();
853     my $VFSType = $backupwkrec->prop('VFSType') || 'smbfs';
854     my $err;
855    
856     my $backupkey = $q->param ('backupset');
857     - if ($backupkey =~ /^(.*)$/) {
858     + if ($backupkey =~ /^(.*)$/)
859     + {
860     $backupkey = $1;
861     - }
862     - else {
863     + }
864     + else
865     + {
866     die('Unsecure data : ' . $backupkey);
867     - }
868     + }
869    
870     # Mounting backup shared folder
871    
872     - if ( $err = dmount($smbhost,$smbshare,$mntdir,$login,$password,$VFSType) )
873     - {
874     + if ($err = dmount($smbhost,$smbshare,$mntdir,$login,$password,$VFSType))
875     + {
876     esmith::cgi::genResult(
877     $q, $fm->localise('ERR_MOUNTING_SMBSHARE') . "\n" . $err
878     );
879     return;
880     - }
881     - elsif ( $VFSType ne 'usb' ) {$mounted = 1}
882     + }
883     + elsif ($VFSType ne 'usb')
884     + {
885     + $mounted = 1;
886     + }
887    
888     # Test if backup subdirectory for our server
889    
890     $mntbkdir = $mntdir . "/$id";
891     - unless ( -d $mntbkdir)
892     - {
893     - if ($mounted) {
894     + unless (-d $mntbkdir)
895     + {
896     + if ($mounted)
897     + {
898     system("/bin/umount $mntdir") == 0
899     or die($fm->localise('ERR_WHILE_UNMOUNTING'),"\n");
900     - }
901     + }
902     esmith::cgi::genResult(
903     $q, $fm->localise('ERR_NO_HOST_DIR'.$id)
904     );
905     return;
906     - }
907     + }
908    
909     # Read wanted file list from selected backup
910    
911     @@ -2955,10 +3005,11 @@
912     system ("/usr/bin/dar_manager -B $mntbkdir/dar-catalog -u $backupkey") == 0
913     or die ($fm->localise('ERR_EXTRACT')." : ".$!);
914    
915     - if ($mounted) {
916     + if ($mounted)
917     + {
918     system("/bin/umount $mntdir") == 0
919     or die($fm->localise('ERR_WHILE_UNMOUNTING'),"\n");
920     - }
921     + }
922     exit(0);
923     }
924    
925     @@ -3024,35 +3075,43 @@
926    
927     my @restorelist;
928     my $when = $q->param ('seldatebefore');
929     - if ($when =~ /^(.*)$/) {
930     + if ($when =~ /^(.*)$/)
931     + {
932     $when = $1;
933     - }
934     - else {
935     + }
936     + else
937     + {
938     die('Unsecure data : ' . $when);
939     - }
940     - my $tymd = qr/((19|20)\d\d\/(?=\d\d\/\d\d-))?((0?[1-9]|1[0-2])\/(?=\d\d-))?((31|[123]0|[012]?[1-9])-)?/;
941     - my $thms = qr/([01]?[0-9]|2[0-3]):([0-5][0-9])(:[0-5][0-9])?/;
942     + }
943     + my $tymd =
944     + qr/((19|20)\d\d\/(?=\d\d\/\d\d-))?((0?[1-9]|1[0-2])\/(?=\d\d-))?((31|[123]0|[012]?[1-9])-)?/;
945     + my $thms =
946     + qr/([01]?[0-9]|2[0-3]):([0-5][0-9])(:[0-5][0-9])?/;
947    
948     - unless (($when =~ m/^$tymd$thms$/) || ($when eq "")) {
949     + unless (($when =~ m/^$tymd$thms$/) || ($when eq ""))
950     + {
951     esmith::cgi::genResult(
952     $q, "$when : " . $fm->localise('ERR_INVALID_SELDATE')
953     );
954     return;
955     - }
956     + }
957    
958     my $f;
959     - foreach $f ($q->param ('restorefiles')) {
960     - if ($f =~ /^(.*)$/) {
961     + foreach $f ($q->param ('restorefiles'))
962     + {
963     + if ($f =~ /^(.*)$/)
964     + {
965     push @restorelist, "\"".$1."\"";
966     - }
967     }
968     + }
969    
970     # mounting backup shared folder
971    
972     my $backupwkrec = $conf->get('backupwk');
973     my $login = $backupwkrec->prop('Login');
974     my $password = $backupwkrec->prop('Password');
975     - my $id = $backupwkrec->prop('Id') || $conf->get('SystemName')->value . "." . $conf->get('DomainName')->value;
976     + my $id = $backupwkrec->prop('Id') ||
977     + $conf->get('SystemName')->value . "." . $conf->get('DomainName')->value;
978     my $mntdir = $backupwkrec->prop('MountDir') || '/mnt/smb';
979     my $mounted;
980     my $VFSType = $backupwkrec->prop('VFSType') || 'smbfs';
981     @@ -3060,29 +3119,33 @@
982     my $smbshare = $backupwkrec->prop('SmbShare');
983     my $err;
984    
985     - if ( $err = dmount($smbhost,$smbshare,$mntdir,$login,$password,$VFSType) )
986     - {
987     + if ($err = dmount($smbhost,$smbshare,$mntdir,$login,$password,$VFSType))
988     + {
989     esmith::cgi::genResult(
990     $q, $fm->localise('ERR_MOUNTING_SMBSHARE') . "\n" . $err
991     );
992     return;
993     - }
994     - elsif ( $VFSType ne 'usb' ) {$mounted = 1}
995     + }
996     + elsif ($VFSType ne 'usb')
997     + {
998     + $mounted = 1;
999     + }
1000    
1001     # Test if backup subdirectory for our server
1002    
1003     my $mntbkdir = $mntdir . "/$id";
1004     - unless ( -d $mntbkdir)
1005     - {
1006     - if ($mounted) {
1007     + unless (-d $mntbkdir)
1008     + {
1009     + if ($mounted)
1010     + {
1011     system("/bin/umount $mntdir") == 0
1012     or die($fm->localise('ERR_WHILE_UNMOUNTING'),"\n");
1013     - }
1014     + }
1015     esmith::cgi::genResult(
1016     $q, $fm->localise('ERR_NO_HOST_DIR'.$id)
1017     );
1018     return;
1019     - }
1020     + }
1021    
1022     # backup is online, restoring now
1023    
1024     @@ -3140,16 +3203,15 @@
1025     $restorerr = system ("/usr/bin/dar_manager -B $mntbkdir/dar-catalog -e '-N -R / -w' -r @restorelist");
1026     }
1027    
1028     - if ($mounted) {
1029     + if ($mounted)
1030     + {
1031     system("/bin/umount $mntdir") == 0
1032     or die($fm->localise('ERR_WHILE_UNMOUNTING'),"\n");
1033     - }
1034     + }
1035    
1036     exit(0);
1037     }
1038     -
1039     return;
1040     -
1041     }
1042    
1043     sub performReboot ()
1044     @@ -3320,21 +3382,27 @@
1045    
1046     my ($host,$share,$mountdir,$login,$password,$VFSType) = @_;
1047    
1048     - if ($VFSType eq 'cifs'){
1049     + if ($VFSType eq 'cifs')
1050     + {
1051     return ( qx(/bin/mount -t cifs $host:$share $mountdir -o user=$login,pass=$password) );
1052     - }
1053     - elsif ($VFSType eq 'smbfs'){
1054     + }
1055     + elsif ($VFSType eq 'smbfs')
1056     + {
1057     return ( qx(/bin/mount -t smbfs //$host/$share $mountdir -o username=$login,password=$password,dmask=777,fmask=777,ip=$host 2>&1) );
1058     - }
1059     - elsif ($VFSType eq 'nfs'){
1060     + }
1061     + elsif ($VFSType eq 'nfs')
1062     + {
1063     return ( qx(/bin/mount -t nfs -o nolock $host:/$share $mountdir 2>&1) );
1064     - }
1065     - elsif ($VFSType eq 'usb'){
1066     + }
1067     + elsif ($VFSType eq 'usb')
1068     + {
1069     $_[2] = "/" . $share;
1070     return
1071     - }
1072     - else {return ("Error while mounting $host/$share : $VFSType not supported.\n")}
1073     -
1074     + }
1075     + else
1076     + {
1077     + return ("Error while mounting $host/$share : $VFSType not supported.\n");
1078     + }
1079     }
1080    
1081     __DATA__

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