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

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

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


Revision 1.1 - (hide annotations) (download)
Sun Apr 20 22:55:40 2014 UTC (10 years, 1 month ago) by wellsi
Branch: MAIN
CVS Tags: 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-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
* Sun Apr 20 2014 Ian Wells <esmith@wellsi.com> 2.4.0-33.sme
- Implement verify workstation backup for mounted drive [SME: 8144]

1 wellsi 1.1 diff -ruN e-smith-backup-2.4.0.old/root/etc/e-smith/locale/en-us/etc/e-smith/web/functions/backup e-smith-backup-2.4.0/root/etc/e-smith/locale/en-us/etc/e-smith/web/functions/backup
2     --- e-smith-backup-2.4.0.old/root/etc/e-smith/locale/en-us/etc/e-smith/web/functions/backup 2014-04-19 10:05:05.000000000 -0700
3     +++ e-smith-backup-2.4.0/root/etc/e-smith/locale/en-us/etc/e-smith/web/functions/backup 2014-04-19 20:55:51.000000000 -0700
4     @@ -637,10 +637,18 @@
5     <trans>Invalid Password</trans>
6     </entry>
7     <entry>
8     + <base>ERR_ALREADY_MOUNTED</base>
9     + <trans>Backup directory is already mounted</trans>
10     + </entry>
11     + <entry>
12     <base>ERR_MOUNTING_SMBSHARE</base>
13     <trans>Unable to mount workstation shared folder</trans>
14     </entry>
15     <entry>
16     + <base>ERR_NOT_MOUNTED</base>
17     + <trans>Backup directory is not mounted</trans>
18     + </entry>
19     + <entry>
20     <base>WORKSTN_NOT_SET</base>
21     <trans>You must first correctly configure your workstation backup</trans>
22     </entry>
23     diff -ruN e-smith-backup-2.4.0.old/root/etc/e-smith/web/functions/backup e-smith-backup-2.4.0/root/etc/e-smith/web/functions/backup
24     --- e-smith-backup-2.4.0.old/root/etc/e-smith/web/functions/backup 2014-04-19 10:05:05.000000000 -0700
25     +++ e-smith-backup-2.4.0/root/etc/e-smith/web/functions/backup 2014-04-20 15:38:39.000000000 -0700
26     @@ -1725,9 +1725,8 @@
27     }
28    
29     my %backupfiles = ();
30     - my $mntdir = $rec->prop('MountDir') || '/mnt/smb';
31     + my $mntdir = $rec->prop('Mount') || '/mnt/smb';
32     my $mntbkdir;
33     - my $mounted;
34     my $key;
35     my $id = $rec->prop('Id') || $conf->get('SystemName')->value . "." . $conf->get('DomainName')->value;
36     my $smbhost = $rec->prop('SmbHost');
37     @@ -1749,38 +1748,22 @@
38     };
39    
40     # Mounting backup shared folder
41     -
42     - unless (-d $mntdir)
43     + my $error_message = bmount($mntdir,$smbhost,$smbshare,$VFSType);
44     + if ($error_message)
45     {
46     - mkdir -p $mntdir;
47     + esmith::cgi::genResult($q, $error_message, $id);
48     + return;
49     }
50    
51     - my $login = $rec->prop('Login') || 'backup';
52     - my $password = $rec->prop('Password') || 'backup';
53     -
54     - if ( $err = dmount($smbhost,$smbshare,$mntdir,$login,$password,$VFSType) )
55     - {
56     - esmith::cgi::genResult(
57     - $q, $fm->localise('ERR_MOUNTING_SMBSHARE') . "\n" . $err
58     - );
59     - return;
60     - }
61     - else {$mounted = 1}
62     -
63     # Test if backup subdirectory for our server
64     -
65     - $mntbkdir = $mntdir . '/' . $id;
66     - unless ( -d $mntbkdir)
67     - {
68     - if ($mounted) {
69     - system("/bin/umount", "$mntdir") == 0
70     - or die($fm->localise('ERR_WHILE_UNMOUNTING'),"\n");
71     - }
72     - esmith::cgi::genResult(
73     - $q, $fm->localise('ERR_NO_HOST_DIR'), $id
74     - );
75     - return;
76     - }
77     + $mntbkdir = $mntdir . "/$id";
78     + unless (-d $mntbkdir)
79     + {
80     + $error_message = $fm->localise('ERR_NO_HOST_DIR')."\n";
81     + $error_message .= bunmount($mntdir,$VFSType);
82     + esmith::cgi::genResult($q, $error_message, $id);
83     + return;
84     + }
85    
86     # Finding existing backups
87    
88     @@ -1796,10 +1779,8 @@
89     $backups = push @blabels, $labkey;
90     }
91    
92     - if ($mounted) {
93     - system("/bin/umount", "$mntdir") == 0
94     - or die($fm->localise('ERR_WHILE_UNMOUNTING'),"\n");
95     - }
96     + $error_message = bunmount($mntdir,$VFSType);
97     + die($error_message) if $error_message;
98    
99     # Stops here if no backups
100    
101     @@ -1877,43 +1858,34 @@
102     my $backupwkrec = $conf->get('backupwk');
103     my $smbhost = $backupwkrec->prop('SmbHost');
104     my $smbshare = $backupwkrec->prop('SmbShare');
105     - my $login = $backupwkrec->prop('Login');
106     - my $password = $backupwkrec->prop('Password');
107     - my $mntdir = $backupwkrec->prop('MountDir') || '/mnt/smb';
108     - my $mounted;
109     + my $mntdir = $backupwkrec->prop('Mount') || '/mnt/smb';
110     my $key;
111     + my $error_message;
112     my $id = $backupwkrec->prop('Id') ||
113     $conf->get('SystemName')->value . "." . $conf->get('DomainName')->value;
114     my $err;
115     my $VFSType = $backupwkrec->prop('VFSType') || 'cifs';
116     my $verifyref = $q->param ('backupset');
117     -
118     +
119     # Mounting backup shared folder
120     -
121     - if ($err = dmount($smbhost,$smbshare,$mntdir,$login,$password,$VFSType))
122     - {
123     - esmith::cgi::genResult(
124     - $q, $fm->localise('ERR_MOUNTING_SMBSHARE') . "\n" . $err
125     - );
126     - return;
127     + $error_message = bmount($mntdir,$smbhost,$smbshare,$VFSType);
128     + if ($error_message)
129     + {
130     + esmith::cgi::genResult($q, $error_message, $id);
131     + return;
132     }
133     - else {$mounted = 1}
134    
135     # Test if backup subdirectory for our server
136     -
137     my $mntbkdir = $mntdir . "/$id";
138     unless (-d $mntbkdir)
139     - {
140     - if ($mounted)
141     - {
142     - system("/bin/umount", "$mntdir") == 0
143     - or die($fm->localise('ERR_WHILE_UNMOUNTING'),"\n");
144     - }
145     - esmith::cgi::genResult($q, $fm->localise('ERR_NO_HOST_DIR'), $id);
146     - return;
147     + {
148     + $error_message = $fm->localise('ERR_NO_HOST_DIR')."\n";
149     + $error_message .= bunmount($mntdir,$VFSType);
150     + esmith::cgi::genResult($q, $error_message, $id);
151     + return;
152     }
153    
154     - my $fullverify = $q->param('verifyall');
155     + my $fullverify = $q->param('verifyall') || '';
156    
157     if ( $fullverify eq "on" )
158     {
159     @@ -2010,62 +1982,53 @@
160     }
161    
162     esmith::cgi::genFooter ($q);
163     - }
164     - else
165     - {
166     - select(STDOUT);
167     - $| = 1;
168     -
169     - my $file;
170     - foreach $file (@restorefiles)
171     - {
172     - if ($file =~ /^(.*)$/)
173     - {
174     - $file = $1;
175     - }
176     - else
177     - {
178     - if ($mounted)
179     - {
180     - system("/bin/umount", "$mntdir") == 0
181     - or die($fm->localise('ERR_WHILE_UNMOUNTING'),"\n");
182     - }
183     - die('Unsecure data : ' . $file);
184     - }
185     - print $q->p($fm->localise('TESTED_BACKUP') . " " . $file);
186     - system ("/usr/bin/dar", "-Q", "--test", "$file", "--noconf");
187     - }
188     + }
189     + else
190     + {
191     + select(STDOUT);
192     + $| = 1;
193    
194     - if ($mounted)
195     - {
196     - system("/bin/umount", "$mntdir") == 0
197     - or die($fm->localise('ERR_WHILE_UNMOUNTING'),"\n");
198     - }
199     + my $file;
200     + foreach $file (@restorefiles)
201     + {
202     + if ($file =~ /^(.*)$/)
203     + {
204     + $file = $1;
205     + }
206     + else
207     + {
208     + $error_message = "Unsecure data : $file\n";
209     + $error_message .= bunmount($mntdir,$VFSType);
210     + die ($error_message);
211     + }
212     + print $q->p($fm->localise('TESTED_BACKUP') . " " . $file);
213     + system ("/usr/bin/dar", "-Q", "--test", "$file", "--noconf");
214     + }
215    
216     - exit(0);
217     - }
218     - return;
219     + $error_message = bunmount($mntdir,$VFSType);
220     + die($error_message) if $error_message;
221     +
222     + exit(0);
223     + }
224     + return;
225    
226     }
227     else
228     {
229     - # verify selected backup only
230     - # and display files saved in the backup
231     -
232     - my $backupkey = $verifyref;
233     + # verify selected backup only
234     + # and display files saved in the backup
235     +
236     + my $backupkey = $verifyref;
237     if ($backupkey =~ /^(.*)$/)
238     - {
239     - $backupkey = $1;
240     - }
241     - else
242     - {
243     - if ($mounted)
244     - {
245     - system("/bin/umount", "$mntdir") == 0
246     - or die($fm->localise('ERR_WHILE_UNMOUNTING'),"\n");
247     - }
248     - die('Unsecure data : ' . $backupkey);
249     - }
250     + {
251     + $backupkey = $1;
252     + }
253     + else
254     + {
255     + $error_message = "Unsecure data : $backupkey\n";
256     + $error_message .= bunmount($mntdir,$VFSType);
257     + die ($error_message);
258     + }
259    
260     if (open(RD, "-|"))
261     {
262     @@ -2092,21 +2055,19 @@
263    
264     esmith::cgi::genFooter ($q);
265    
266     - }
267     - else
268     - {
269     - select(STDOUT);
270     - $| = 1;
271     -
272     - system ("/usr/bin/dar", "-Q", "--list", "$backupkey", "--noconf") == 0
273     - or die ($fm->localise('ERR_EXTRACT')." : ".$!);
274     -
275     - if ($mounted) {
276     - system("/bin/umount", "$mntdir") == 0
277     - or die($fm->localise('ERR_WHILE_UNMOUNTING'),"\n");
278     - }
279     - exit(0);
280     - }
281     + }
282     + else
283     + {
284     + select(STDOUT);
285     + $| = 1;
286     +
287     + system ("/usr/bin/dar", "-Q", "--list", "$backupkey", "--noconf") == 0
288     + or die ($fm->localise('ERR_EXTRACT')." : ".$!);
289     +
290     + $error_message = bunmount($mntdir,$VFSType);
291     + die($error_message) if $error_message;
292     + exit(0);
293     + }
294     }
295    
296     return;
297     @@ -3165,7 +3126,7 @@
298     return $size;
299     }
300    
301     -sub dmount()
302     +sub dmount
303     {
304     # mount dar unit according to dar-workstation configuration
305     # return nothing if mount successfull
306     @@ -3215,6 +3176,66 @@
307     }
308     }
309    
310     +sub checkMount
311     +{
312     + # check if $mountdir is mounted
313     + my $mountdir = shift;
314     + return system("/bin/mountpoint", "-q", "$mountdir");
315     +}
316     +
317     +sub bmount
318     +{
319     + my ($mntdir,$host,$share,$VFSType) = @_;
320     + # verify backup directory not already mounted
321     +
322     + if (!checkMount ($mntdir))
323     + {
324     + return if ($VFSType eq 'mnt');
325     + return ($fm->localise('ERR_ALREADY_MOUNTED'));
326     + }
327     + else
328     + {
329     + if ($VFSType eq 'mnt')
330     + {
331     + return ($fm->localise('ERR_NOT_MOUNTED'));
332     + }
333     + }
334     +
335     + # create the directory mount point if it does not exist
336     + createTree ($mntdir);
337     +
338     + # mount the backup directory
339     + my $err = dmount($host,$share,$mntdir,'','',$VFSType);
340     + return ($fm->localise('ERR_MOUNTING_SMBSHARE') . "<//$host/$share>\n" . $err) if $err;
341     +
342     + # verify $mntdir is mounted
343     + if (checkMount ($mntdir))
344     + {
345     + # The mount should have suceeded, but sometimes it needs more time,
346     + # so sleep and then check again.
347     + sleep 5;
348     + if (checkMount ($mntdir))
349     + {
350     + return ($fm->localise('ERR_NOT_MOUNTED'));
351     + }
352     + }
353     + return;
354     +}
355     +
356     +sub bunmount
357     +{
358     + my ($mount,$type) = @_;
359     + return if ($type eq 'mnt'); # Don't unmount for type 'mnt'
360     +
361     + if (!checkMount ($mount))
362     + {
363     + system('/bin/umount', '-f', $mount) == 0
364     + or return ($fm->localise('ERR_WHILE_UNMOUNTING'));
365     + }
366     + return;
367     +}
368     +
369     +
370     __DATA__
371     <form>
372     </form>

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