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

Contents of /rpms/e-smith-backup/sme7/e-smith-backup-1.15.0-DarWorkstation.patch

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


Revision 1.2 - (show annotations) (download)
Tue Oct 7 19:27:49 2008 UTC (16 years, 1 month ago) by slords
Branch: MAIN
CVS Tags: HEAD
Changes since 1.1: +0 -0 lines
FILE REMOVED
New streams

1 diff -Nur -x '*.orig' -x '*.rej' e-smith-backup-1.15.0/root/etc/e-smith/db/configuration/defaults/backupwk/BackupTime mezzanine_patched_e-smith-backup-1.15.0/root/etc/e-smith/db/configuration/defaults/backupwk/BackupTime
2 --- e-smith-backup-1.15.0/root/etc/e-smith/db/configuration/defaults/backupwk/BackupTime 1969-12-31 19:00:00.000000000 -0500
3 +++ mezzanine_patched_e-smith-backup-1.15.0/root/etc/e-smith/db/configuration/defaults/backupwk/BackupTime 2007-09-05 15:53:17.000000000 -0400
4 @@ -0,0 +1 @@
5 +22:00
6 diff -Nur -x '*.orig' -x '*.rej' e-smith-backup-1.15.0/root/etc/e-smith/db/configuration/defaults/backupwk/Compression mezzanine_patched_e-smith-backup-1.15.0/root/etc/e-smith/db/configuration/defaults/backupwk/Compression
7 --- e-smith-backup-1.15.0/root/etc/e-smith/db/configuration/defaults/backupwk/Compression 1969-12-31 19:00:00.000000000 -0500
8 +++ mezzanine_patched_e-smith-backup-1.15.0/root/etc/e-smith/db/configuration/defaults/backupwk/Compression 2007-09-05 15:53:22.000000000 -0400
9 @@ -0,0 +1 @@
10 +4
11 diff -Nur -x '*.orig' -x '*.rej' e-smith-backup-1.15.0/root/etc/e-smith/db/configuration/defaults/backupwk/DaysInSet mezzanine_patched_e-smith-backup-1.15.0/root/etc/e-smith/db/configuration/defaults/backupwk/DaysInSet
12 --- e-smith-backup-1.15.0/root/etc/e-smith/db/configuration/defaults/backupwk/DaysInSet 1969-12-31 19:00:00.000000000 -0500
13 +++ mezzanine_patched_e-smith-backup-1.15.0/root/etc/e-smith/db/configuration/defaults/backupwk/DaysInSet 2007-09-05 15:54:31.000000000 -0400
14 @@ -0,0 +1 @@
15 +1
16 diff -Nur -x '*.orig' -x '*.rej' e-smith-backup-1.15.0/root/etc/e-smith/db/configuration/defaults/backupwk/IncOnlyTimeout mezzanine_patched_e-smith-backup-1.15.0/root/etc/e-smith/db/configuration/defaults/backupwk/IncOnlyTimeout
17 --- e-smith-backup-1.15.0/root/etc/e-smith/db/configuration/defaults/backupwk/IncOnlyTimeout 1969-12-31 19:00:00.000000000 -0500
18 +++ mezzanine_patched_e-smith-backup-1.15.0/root/etc/e-smith/db/configuration/defaults/backupwk/IncOnlyTimeout 2007-09-05 15:54:38.000000000 -0400
19 @@ -0,0 +1 @@
20 +no
21 diff -Nur -x '*.orig' -x '*.rej' e-smith-backup-1.15.0/root/etc/e-smith/db/configuration/defaults/backupwk/Login mezzanine_patched_e-smith-backup-1.15.0/root/etc/e-smith/db/configuration/defaults/backupwk/Login
22 --- e-smith-backup-1.15.0/root/etc/e-smith/db/configuration/defaults/backupwk/Login 1969-12-31 19:00:00.000000000 -0500
23 +++ mezzanine_patched_e-smith-backup-1.15.0/root/etc/e-smith/db/configuration/defaults/backupwk/Login 2007-09-05 15:54:43.000000000 -0400
24 @@ -0,0 +1 @@
25 +backup
26 diff -Nur -x '*.orig' -x '*.rej' e-smith-backup-1.15.0/root/etc/e-smith/db/configuration/defaults/backupwk/Password mezzanine_patched_e-smith-backup-1.15.0/root/etc/e-smith/db/configuration/defaults/backupwk/Password
27 --- e-smith-backup-1.15.0/root/etc/e-smith/db/configuration/defaults/backupwk/Password 1969-12-31 19:00:00.000000000 -0500
28 +++ mezzanine_patched_e-smith-backup-1.15.0/root/etc/e-smith/db/configuration/defaults/backupwk/Password 2007-09-05 15:56:11.000000000 -0400
29 @@ -0,0 +1 @@
30 +backup
31 diff -Nur -x '*.orig' -x '*.rej' e-smith-backup-1.15.0/root/etc/e-smith/db/configuration/defaults/backupwk/Program mezzanine_patched_e-smith-backup-1.15.0/root/etc/e-smith/db/configuration/defaults/backupwk/Program
32 --- e-smith-backup-1.15.0/root/etc/e-smith/db/configuration/defaults/backupwk/Program 1969-12-31 19:00:00.000000000 -0500
33 +++ mezzanine_patched_e-smith-backup-1.15.0/root/etc/e-smith/db/configuration/defaults/backupwk/Program 2007-09-05 15:56:15.000000000 -0400
34 @@ -0,0 +1 @@
35 +dar
36 diff -Nur -x '*.orig' -x '*.rej' e-smith-backup-1.15.0/root/etc/e-smith/db/configuration/defaults/backupwk/SetsMax mezzanine_patched_e-smith-backup-1.15.0/root/etc/e-smith/db/configuration/defaults/backupwk/SetsMax
37 --- e-smith-backup-1.15.0/root/etc/e-smith/db/configuration/defaults/backupwk/SetsMax 1969-12-31 19:00:00.000000000 -0500
38 +++ mezzanine_patched_e-smith-backup-1.15.0/root/etc/e-smith/db/configuration/defaults/backupwk/SetsMax 2007-09-05 15:58:44.000000000 -0400
39 @@ -0,0 +1 @@
40 +1
41 diff -Nur -x '*.orig' -x '*.rej' e-smith-backup-1.15.0/root/etc/e-smith/db/configuration/defaults/backupwk/SmbHost mezzanine_patched_e-smith-backup-1.15.0/root/etc/e-smith/db/configuration/defaults/backupwk/SmbHost
42 --- e-smith-backup-1.15.0/root/etc/e-smith/db/configuration/defaults/backupwk/SmbHost 1969-12-31 19:00:00.000000000 -0500
43 +++ mezzanine_patched_e-smith-backup-1.15.0/root/etc/e-smith/db/configuration/defaults/backupwk/SmbHost 2007-09-05 15:55:01.000000000 -0400
44 @@ -0,0 +1 @@
45 +host
46 diff -Nur -x '*.orig' -x '*.rej' e-smith-backup-1.15.0/root/etc/e-smith/db/configuration/defaults/backupwk/SmbShare mezzanine_patched_e-smith-backup-1.15.0/root/etc/e-smith/db/configuration/defaults/backupwk/SmbShare
47 --- e-smith-backup-1.15.0/root/etc/e-smith/db/configuration/defaults/backupwk/SmbShare 1969-12-31 19:00:00.000000000 -0500
48 +++ mezzanine_patched_e-smith-backup-1.15.0/root/etc/e-smith/db/configuration/defaults/backupwk/SmbShare 2007-09-05 15:58:49.000000000 -0400
49 @@ -0,0 +1 @@
50 +share
51 diff -Nur -x '*.orig' -x '*.rej' e-smith-backup-1.15.0/root/etc/e-smith/db/configuration/defaults/backupwk/status mezzanine_patched_e-smith-backup-1.15.0/root/etc/e-smith/db/configuration/defaults/backupwk/status
52 --- e-smith-backup-1.15.0/root/etc/e-smith/db/configuration/defaults/backupwk/status 1969-12-31 19:00:00.000000000 -0500
53 +++ mezzanine_patched_e-smith-backup-1.15.0/root/etc/e-smith/db/configuration/defaults/backupwk/status 2007-09-05 15:55:09.000000000 -0400
54 @@ -0,0 +1 @@
55 +disabled
56 diff -Nur -x '*.orig' -x '*.rej' e-smith-backup-1.15.0/root/etc/e-smith/db/configuration/defaults/backupwk/Timeout mezzanine_patched_e-smith-backup-1.15.0/root/etc/e-smith/db/configuration/defaults/backupwk/Timeout
57 --- e-smith-backup-1.15.0/root/etc/e-smith/db/configuration/defaults/backupwk/Timeout 1969-12-31 19:00:00.000000000 -0500
58 +++ mezzanine_patched_e-smith-backup-1.15.0/root/etc/e-smith/db/configuration/defaults/backupwk/Timeout 2007-09-05 15:58:55.000000000 -0400
59 @@ -0,0 +1 @@
60 +8
61 diff -Nur -x '*.orig' -x '*.rej' e-smith-backup-1.15.0/root/etc/e-smith/db/configuration/defaults/backupwk/type mezzanine_patched_e-smith-backup-1.15.0/root/etc/e-smith/db/configuration/defaults/backupwk/type
62 --- e-smith-backup-1.15.0/root/etc/e-smith/db/configuration/defaults/backupwk/type 1969-12-31 19:00:00.000000000 -0500
63 +++ mezzanine_patched_e-smith-backup-1.15.0/root/etc/e-smith/db/configuration/defaults/backupwk/type 2007-09-05 15:56:22.000000000 -0400
64 @@ -0,0 +1 @@
65 +service
66 diff -Nur -x '*.orig' -x '*.rej' e-smith-backup-1.15.0/root/etc/e-smith/db/configuration/defaults/backupwk/VFSType mezzanine_patched_e-smith-backup-1.15.0/root/etc/e-smith/db/configuration/defaults/backupwk/VFSType
67 --- e-smith-backup-1.15.0/root/etc/e-smith/db/configuration/defaults/backupwk/VFSType 1969-12-31 19:00:00.000000000 -0500
68 +++ mezzanine_patched_e-smith-backup-1.15.0/root/etc/e-smith/db/configuration/defaults/backupwk/VFSType 2007-09-05 15:56:26.000000000 -0400
69 @@ -0,0 +1 @@
70 +smbfs
71 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
72 --- e-smith-backup-1.15.0/root/etc/e-smith/events/actions/workstation-backup-dar 1969-12-31 19:00:00.000000000 -0500
73 +++ mezzanine_patched_e-smith-backup-1.15.0/root/etc/e-smith/events/actions/workstation-backup-dar 2007-09-05 15:52:45.000000000 -0400
74 @@ -0,0 +1,267 @@
75 +#!/usr/bin/perl -w
76 +
77 +#----------------------------------------------------------------------
78 +# copyright (C) 2006 Jean-Paul Leclere <jean-paul@leclere.org>
79 +#
80 +# This program is free software; you can redistribute it and/or modify
81 +# it under the terms of the GNU General Public License as published by
82 +# the Free Software Foundation; either version 2 of the License, or
83 +# (at your option) any later version.
84 +#
85 +# This program is distributed in the hope that it will be useful,
86 +# but WITHOUT ANY WARRANTY; without even the implied warranty of
87 +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
88 +# GNU General Public License for more details.
89 +#
90 +# You should have received a copy of the GNU General Public License
91 +# along with this program; if not, write to the Free Software
92 +# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
93 +#
94 +#----------------------------------------------------------------------
95 +
96 +use strict;
97 +use Errno;
98 +use esmith::util;
99 +use esmith::templates;
100 +use Time::localtime;
101 +use File::Copy;
102 +use File::Path;
103 +use esmith::ConfigDB;
104 +
105 +sub ldie;
106 +
107 +my $job = shift || 'DailyBackup';
108 +my $report;
109 +
110 +my $confdb = esmith::ConfigDB->open;
111 +my $backupwk = $confdb->get('backupwk') or die "No backupwk db entry found\n";
112 +
113 +my $tm = localtime(time);
114 +my $bkname = $tm->year+1900;
115 + if (($tm->mon) < 9) {$bkname .= ("0".($tm->mon+1))} else {$bkname .= ($tm->mon+1)}
116 + if (($tm->mday) < 10) {$bkname .= ("0".$tm->mday)} else {$bkname .= $tm->mday}
117 +my $dow = $tm->wday;
118 +my $id = $backupwk->prop('Id') || $confdb->get('SystemName')->value . "." . $confdb->get('DomainName')->value;
119 +my $err;
120 +my $ref = "";
121 +my $mntdone = 0;
122 +my $tim = ctime();
123 +
124 +my $smbhost = $backupwk->prop('SmbHost');
125 +my $smbshare = $backupwk->prop('SmbShare');
126 +my $login = $backupwk->prop('Login');
127 +my $password = $backupwk->prop('Password');
128 +my $setsmax = $backupwk->prop('SetsMax') || 1;
129 +my $daysinset = $backupwk->prop('DaysInSet') || 1;
130 +my $setnum = $backupwk->prop('SetNum'); $setnum = ($setsmax-1) unless defined $setnum;
131 +my $incnum = $backupwk->prop('IncNum'); $incnum = ($daysinset-1) unless defined $incnum;
132 +my $timeout = (($backupwk->prop('Timeout') * 3600) - 30) || '88500';
133 +my $inconly = $backupwk->prop('IncOnlyTimeout') || 'no';
134 +my $VFSType = $backupwk->prop('VFSType') || 'smbfs';
135 +my $fullday = $backupwk->prop('FullDay') || 7;
136 +my $mail = $backupwk->prop('MailNotify') || 'yes';
137 +my $mntdir = $backupwk->prop('Mount') || '/mnt/smb';
138 +my $tmpdir = $mntdir . "/tmp_dir";
139 +
140 +$report .= "From: Backup-Program\n";
141 +$report .= "Subject: Daily Backup Report\n\n";
142 +$report .= "================================== \n";
143 +$report .= "DAILY BACKUP TO WORKSTATION REPORT \n";
144 +$report .= "================================== \n";
145 +$report .= "Backup started at " .$tim . "\n";
146 +$report .= "Backup of mysql databases has been done.\n";
147 +
148 +# mounting backup directory
149 +
150 +$report .= "Mounting backup shared directory $smbhost/$smbshare \n";
151 +
152 +# verify backup directory not already mounted
153 +
154 +if ( $VFSType ne 'usb' ) {
155 + open FD, '/proc/mounts';
156 + while (<FD>) {
157 + next unless /$smbhost(.*)\/$smbshare/;
158 + next unless /$mntdir/;
159 + $err++
160 + }
161 + close FD;
162 + if ($err) {
163 + ldie("Seems backup directory is already mounted. It should not happen \
164 +and maybe there is a zombie process you must kill, or another backup in progress. \n")
165 + }
166 + if ($VFSType eq 'cifs'){
167 + $err = qx(/bin/mount -t cifs $smbhost:$smbshare $mntdir -o user=$login,pass=$password);
168 + if ($err) {ldie("Error while mounting $smbhost:$smbshare : \n" . $err)};
169 + }
170 + elsif ($VFSType eq 'smbfs'){
171 + $err = qx(/bin/mount -t smbfs //$smbhost/$smbshare $mntdir -o username=$login,password=$password,dmask=777,fmask=777,ip=$smbhost 2>&1);
172 + if ($err) {ldie("Error while mounting //$smbhost/$smbshare : \n" . $err)};
173 + }
174 + elsif ($VFSType eq 'nfs'){
175 + $err = qx(/bin/mount -t nfs -o nolock $smbhost:/$smbshare $mntdir 2>&1);
176 + if ($err) {ldie("Error while mounting $smbhost:/$smbshare : \n" . $err)};
177 + }
178 + else {ldie("Error while mounting $smbhost/$smbshare : $VFSType not supported.\n")}
179 +
180 + $mntdone = 1;
181 + }
182 +else { $mntdir = "/".$smbshare }
183 +
184 +if (-d "$tmpdir/$id") {
185 + eval {rmtree("$tmpdir/$id")};
186 + if ($@) {ldie("Error while deleting $tmpdir/$id : $@.\n")}
187 + }
188 +eval {mkpath("$tmpdir/$id")};
189 +if ($@) {ldie("Error while creating $tmpdir/$id : $@. Maybe insufficient rights on backup directory.\n")}
190 +
191 +# we know right backup directory is in line and we can write on it.
192 +$report .= "Backup temp directory $tmpdir/$id is mounted and is writable \n";
193 +
194 +# rotating backup indicators
195 +
196 +++$incnum;
197 +$incnum %= $daysinset;
198 +if ( $incnum == 0 ) {
199 + ++$setnum;
200 + $setnum %= $setsmax;
201 + }
202 +
203 +$report .= "Using set number $setnum of $setsmax\n";
204 +if ($incnum == 0) {
205 + $report .= "Attempt to full backup \n";
206 + }
207 +else {
208 + $report .= "Attempt to incremental backup number $incnum of $daysinset\n";
209 + }
210 +
211 +# if no set directory, make it
212 +
213 +my $setname = "set" . $setnum;
214 +my $setdirname = $mntdir . "/$id/" . $setname;
215 +
216 +unless ( -d $setdirname ) {
217 + eval {mkpath($setdirname)};
218 + if ($@) {ldie("Can't create $setdirname : $@.\n")}
219 + $report .= "Backup directory $id/$setname created \n";
220 + }
221 +
222 +# if $incnum <> 0 backup should be incremental
223 +# we find correct reference backup for incremental
224 +
225 +if ( $incnum != 0 ) {
226 + my $file;
227 + opendir(DIR, $setdirname) or ldie("Can't open dir $setdirname $!");
228 + while (defined($file = readdir(DIR))) {
229 + next if $file =~ /^\.\.?$/;
230 + if ( $file =~ /dar$/) {
231 + $ref = $file;
232 + }
233 + }
234 + closedir (DIR);
235 + # if no reference do full backup
236 + if ($ref eq "") {
237 + $incnum = 0;
238 + $report .= "No existing reference backup, will make full backup \n";
239 + $bkname = "full-" . $bkname;
240 + }
241 + else { # removing .dar extension
242 + $ref =~ s/\..*\.dar$//;
243 + $ref = "--ref " . $setdirname . "/" . $ref;
244 + $bkname = "inc-" . sprintf("%03d", $incnum) . "-". $bkname;
245 + }
246 + }
247 +else {
248 + $bkname = "full-" . $bkname;
249 + }
250 +
251 +unless ( ( $incnum != 0 ) || ( $fullday == 7 ) || ( $dow == $fullday ) ) {
252 + my $delay = ($fullday - $dow) % 7;
253 + ldie("Not a permitted day for full backup. Aborting...\nNext full backup in $delay days.\n");
254 + }
255 +
256 +$report .= "Backup base file name is $bkname \n";
257 +$report .= "Making backup on temporary dir... \n";
258 +
259 +# calculate real timeout if we timeout incrementals only.
260 +# timeout of 88500 is a security for aborting backup within 24h
261 +
262 +if ( ($ref eq "") && ($inconly eq "yes")) {
263 + $timeout = 88500;
264 + }
265 +$report .= "using a backup session timeout of : $timeout seconds\n";
266 +
267 +# expanding backup configuration file template
268 +
269 +processTemplate({
270 + TEMPLATE_PATH => "/etc/dar/$job.dcf",
271 + });
272 +
273 +# launching dar backup
274 +
275 +$err = system("/usr/bin/timeout -s TERM $timeout /usr/bin/dar -c $tmpdir/$id/$bkname $ref -B /etc/dar/$job.dcf");
276 +
277 +if ($err == 0)
278 +{
279 +$report .= "Backup completed successfully on temporary dir \n";
280 +}
281 +elsif ($err == 15)
282 +{
283 +$report .= "Partial backup stored on temp dir.\n"
284 + . " Session closed by timeout after $timeout seconds.\n"
285 + . "Not an error, backup process will continue next night.\n";
286 +}
287 +else
288 +{
289 +$err = $err >> 8;
290 +ldie("Dar error during backup : $err \n");
291 +}
292 +
293 +if ($incnum == 0) {
294 + $report .= "Rotating backups in a new set $setdirname. \n";
295 + eval {rmtree($setdirname)};
296 + if ($@) {ldie("Error while deleting $setdirname : $@.\n")}
297 + eval {mkpath("$setdirname")};
298 + if ($@) {ldie("Error while creating $setdirname : $@.\n")}
299 + }
300 +$report .= "Moving backup files to target directory $setdirname \n";
301 +foreach (<$tmpdir/$id/$bkname*>) {
302 + unless ( move($_, $setdirname) )
303 + {ldie("Error while moving backup file $_ from temporary dir $tmpdir/$id to $setdirname : $!")};
304 + }
305 +
306 +# unmount shared folder
307 +
308 +if ( $VFSType ne 'usb' ) {system("/bin/umount -f $mntdir")}
309 +
310 +# time now to update backup configuration
311 +
312 +$report .= "Updating backup configuration data \n";
313 +$backupwk->set_prop('SetNum', $setnum);
314 +$backupwk->set_prop('IncNum', $incnum);
315 +
316 +$tim = ctime();
317 +$report .= "Backup successfully terminated at : $tim \n";
318 +
319 +if ($mail eq 'yes') {
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 + }
325 +
326 +exit (0);
327 +
328 +sub ldie
329 +{
330 +my $errmsg = shift;
331 +$report .= "*** No backup allowed or error during backup ***\n";
332 +$report .= $errmsg;
333 +if (($mail eq 'yes') || ($mail eq 'error')) {
334 + open (MAIL, "|/var/qmail/bin/qmail-inject -a admin")
335 + || die "Cannot start mail program: $!\n";
336 + print MAIL $report;
337 + close(MAIL);
338 + }
339 +if (($mntdone) && ($VFSType ne 'usb')) {system("/bin/umount $mntdir")};
340 +die($errmsg);
341 +}
342 diff -Nur -x '*.orig' -x '*.rej' e-smith-backup-1.15.0/root/etc/e-smith/locale/en-us/etc/e-smith/web/functions/backup mezzanine_patched_e-smith-backup-1.15.0/root/etc/e-smith/locale/en-us/etc/e-smith/web/functions/backup
343 --- e-smith-backup-1.15.0/root/etc/e-smith/locale/en-us/etc/e-smith/web/functions/backup 2007-09-05 15:45:52.000000000 -0400
344 +++ mezzanine_patched_e-smith-backup-1.15.0/root/etc/e-smith/locale/en-us/etc/e-smith/web/functions/backup 2007-09-05 15:52:45.000000000 -0400
345 @@ -11,8 +11,9 @@
346 <base>BACKUP_DESC</base>
347 <trans>
348 <![CDATA[
349 - <P>The server provides two ways to back up and restore
350 - your server: using your local desktop or a tape drive.</P>
351 + <P>The server provides three ways to back up and restore
352 + your server: using your local desktop, a tape drive or a
353 + workstation on your LAN.</P>
354
355 <P>The first method creates a copy of your server configuration and user
356 data files, and downloads it to your local desktop via your web browser.
357 @@ -29,9 +30,19 @@
358 reminder automatically e-mailed to the administrator during the day).
359 Currently your hard disk contains <b>$dumpsize</b> of data.</P>
360
361 - <P>Both restore methods allow you to restore your configuration and user
362 - data files. <b>Ideally, the restore should be performed on a freshly
363 - installed server</b>.</P>
364 + <P>The workstation backup method uses a software package called <I>dar</I>
365 + to back up your server configuration and data files to a workstation
366 + on your LAN (or a local USB disk). This requires you provide a writable share
367 + (smbfs, cifs, or nfs) on the backup workstation or an a local USB disk. You can manage
368 + how many rotating sets of backup are kept on the backup share, and also make each
369 + set doing incremental backup upon several days. The backup is performed
370 + automatically at the selected time every night. Currently
371 + configuration and data files total approximately <b>$tarsize</b> uncompressed.
372 + Twice the compressed data size must be available on the backup share.</P>
373 +
374 + <P>All restore methods allow you to restore your configuration and user
375 + data files. Workstation backup provides individual file restore. <b>Ideally,
376 + full restore should be performed on a freshly installed server</b>.</P>
377 ]]>
378 </trans>
379 </entry>
380 @@ -330,8 +341,8 @@
381 <trans>Error: invalid backup hour: </trans>
382 </entry>
383 <entry>
384 - <base>BETWEEN_1_AND_12</base>
385 - <trans>Please choose an hour between 1 and 12.</trans>
386 + <base>BETWEEN_0_AND_12</base>
387 + <trans>Please choose an hour between 0 and 12.</trans>
388 </entry>
389 <entry>
390 <base>ERR_INVALID_MINUTE</base>
391 @@ -458,5 +469,412 @@
392 ]]>
393 </trans>
394 </entry>
395 -
396 + <entry>
397 + <base>WORKSTN_BACKUPS_DISABLED</base>
398 + <trans>
399 + <![CDATA[
400 + Workstation backups are <b>disabled</b>
401 + ]]>
402 + </trans>
403 + </entry>
404 + <entry>
405 + <base>WORKSTN_BACKUPS_ENABLED</base>
406 + <trans>
407 + <![CDATA[
408 + Workstation backups are currently <b>enabled</b>.
409 + ]]>
410 + </trans>
411 + </entry>
412 + <entry>
413 + <base>WKBACKUPS_RUN_AT</base>
414 + <trans>Regular workstation backups will run at: </trans>
415 + </entry>
416 + <entry>
417 + <base>WORKSTN_CONFIGURE</base>
418 + <trans>Configure workstation backup</trans>
419 + </entry>
420 + <entry>
421 + <base>WORKSTN_VERIFY</base>
422 + <trans>Verify workstation backup</trans>
423 + </entry>
424 + <entry>
425 + <base>WORKSTN_RESTORE</base>
426 + <trans>Restore from workstation</trans>
427 + </entry>
428 + <entry>
429 + <base>CONFIGURE_WORKSTN_BACKUP</base>
430 + <trans>Configure Workstation Backup</trans>
431 + </entry>
432 + <entry>
433 + <base>ENABLE_DISABLE_WORKSTN</base>
434 + <trans>Enable/Disable Daily Workstation Backup</trans>
435 + </entry>
436 + <entry>
437 + <base>ENABLE_WORKSTN_BACKUP</base>
438 + <trans>Enable Workstation Backup</trans>
439 + </entry>
440 + <entry>
441 + <base>WORKSTN_BACKUP_TIME</base>
442 + <trans>Workstation backup time of day (hour/min)</trans>
443 + </entry>
444 + <entry>
445 + <base>UPDATING_WORKSTN_CONF</base>
446 + <trans>Updating workstation backup configuration</trans>
447 + </entry>
448 + <entry>
449 + <base>SUCCESSFULLY_ENABLED_WORKSTN</base>
450 + <trans>Successfully enabled workstation backups</trans>
451 + </entry>
452 + <entry>
453 + <base>SUCCESSFULLY_DISABLED_WORKSTN</base>
454 + <trans>Successfully disabled workstation backups</trans>
455 + </entry>
456 + <entry>
457 + <base>VERIFY_WORKSTN_BACKUP_FILE</base>
458 + <trans>Verify workstation backup file</trans>
459 + </entry>
460 + <entry>
461 + <base>VERIFY_WORKSTN_BACKUP_DESC</base>
462 + <trans>
463 + <![CDATA[
464 + <p>This option will display the names of all files
465 + in a previously created workstation daily backup. You
466 + can use this option to verify the contents of the
467 + backup.<b>You must choose the backup you want to verify</b></p>
468 + <p>You will see all files in the selected backup.</p>
469 + Backup files are verified from shared folder :
470 + ]]>
471 + </trans>
472 + </entry>
473 + <entry>
474 + <base>RESTORE_CONF_FROM_WORKSTN</base>
475 + <trans>Restore server configuration from workstation backup</trans>
476 + </entry>
477 + <entry>
478 + <base>RESTORE_CONF_FROM_WORKSTN_DESC</base>
479 + <trans>
480 + <![CDATA[
481 + <p>This process will restore the configuration and user data files from a
482 + Server workstation backup. <b>The restore
483 + should be performed on a freshly installed Server</b>.</p>
484 + <p>Ensure that choose the right backup to restore below
485 + before proceeding.</p>
486 + <p>After the restore completes you must reboot the server.</p>
487 + Backup will be restored from :
488 + ]]>
489 + </trans>
490 + </entry>
491 + <entry>
492 + <base>RESTORE_FROM_WORKSTN</base>
493 + <trans>Restore From Workstation</trans>
494 + </entry>
495 + <entry>
496 + <base>RESTORING_FROM_WORKSTN</base>
497 + <trans>Restoring From Workstation</trans>
498 + </entry>
499 + <entry>
500 + <base>NOW_RESTORING_FROM_WORKSTN</base>
501 + <trans>
502 + Your server configuration and user data
503 + files are now being restored from workstation shared folder.
504 + </trans>
505 + </entry>
506 + <entry>
507 + <base>ERR_RESTORING_FROM_WORKSTN</base>
508 + <trans>Error occurred restoring files from workstation.</trans>
509 + </entry>
510 + <entry>
511 + <base>ERR_UPDATING_CONF_AFTER_WORKSTN_RESTORE</base>
512 + <trans>Error occurred while updating system configuration after workstation
513 + restore.
514 + </trans>
515 + </entry>
516 + <entry>
517 + <base>WORKSTN_NAME</base>
518 + <trans>Workstation IP or hostname
519 + </trans>
520 + </entry>
521 + <entry>
522 + <base>WORKSTN_BACKUP_SETTINGS</base>
523 + <trans>Workstation Backup Settings</trans>
524 + </entry>
525 + <entry>
526 + <base>SHARED_FOLDER_NAME</base>
527 + <trans>Backup share
528 + </trans>
529 + </entry>
530 + <entry>
531 + <base>WORKSTN_LOGIN</base>
532 + <trans>Login name
533 + </trans>
534 + </entry>
535 + <entry>
536 + <base>WORKSTN_PASSWORD</base>
537 + <trans>Password</trans>
538 + </entry>
539 + <entry>
540 + <base>WORKSTATION_BACKUP_DEST</base>
541 + <trans>Backup workstation settings</trans>
542 + </entry>
543 + <entry>
544 + <base>CONFIGURE_WORKSTN_BACKUP_DESC</base>
545 + <trans>You can set the number of
546 + successive backup sets to keep on the workstation, with automatic rotation.
547 + Each set may contain saved datas for several consecutive days.
548 + In this case first backup of the set is full backup, others daily backups are
549 + incremental. You can also set a time limit for each backup session or for incremental
550 + backups only. When this limit occurs, backup is cleanly stopped and the next
551 + incremental backup will safely continue with unsaved and modified datas.</trans>
552 + </entry>
553 + <entry>
554 + <base>ERR_INVALID_WORKSTN</base>
555 + <trans>Invalid Workstation IP or Hostname
556 + </trans>
557 + </entry>
558 + <entry>
559 + <base>ERR_INVALID_FOLDER</base>
560 + <trans>Invalid share name
561 + </trans>
562 + </entry>
563 + <entry>
564 + <base>ERR_INVALID_LOGIN</base>
565 + <trans>Invalid Login
566 + </trans>
567 + </entry>
568 + <entry>
569 + <base>ERR_INVALID_PASSWORD</base>
570 + <trans>Invalid Password</trans>
571 + </entry>
572 + <entry>
573 + <base>ERR_MOUNTING_SMBSHARE</base>
574 + <trans>Unable to mount workstation shared folder</trans>
575 + </entry>
576 + <entry>
577 + <base>WORKSTN_NOT_SET</base>
578 + <trans>You must first correctly configure your workstation backup</trans>
579 + </entry>
580 + <entry>
581 + <base>NO_BACKUPS_TO_RESTORE</base>
582 + <trans>There is no backup set on configured workstation shared folder. Verify your configuration settings.</trans>
583 + </entry>
584 + <entry>
585 + <base>NUMBER_OF_SETS</base>
586 + <trans>Number of rotating backup sets</trans>
587 + </entry>
588 + <entry>
589 + <base>NUMBER_OF_FILES_IN_SET</base>
590 + <trans>Daily backups in each set</trans>
591 + </entry>
592 + <entry>
593 + <base>ERR_INVALID_SETS_NUMBER</base>
594 + <trans>Sets number must be 1 or greater</trans>
595 + </entry>
596 + <entry>
597 + <base>ERR_INVALID_FILES_IN_SET_NUMBER</base>
598 + <trans>This number must be 1 or greater. First backup in set is <b>full</b> others are <b>incrementals</b></trans>
599 + </entry>
600 + <entry>
601 + <base>WORKSTN_TIMEOUT</base>
602 + <trans>Optional backup session timeout (hours)</trans>
603 + </entry>
604 + <entry>
605 + <base>INC_ONLY_TIMEOUT</base>
606 + <trans>Don't timeout full backup sessions</trans>
607 + </entry>
608 + <entry>
609 + <base>ERR_INVALID_TIMEOUT</base>
610 + <trans>Maximum backup time must be set between 1 and 24 hours</trans>
611 + </entry>
612 + <entry>
613 + <base>ERR_NO_HOST_DIR</base>
614 + <trans>No directory for your host in shared folder. Maybe your host name is different from backup ones</trans>
615 + </entry>
616 + <entry>
617 + <base>ERROR_READING_FILE</base>
618 + <trans>Error while reading files from</trans>
619 + </entry>
620 + <entry>
621 + <base>WORKSTN_SEL_RESTORE</base>
622 + <trans>Selective file restore from workstation</trans>
623 + </entry>
624 + <entry>
625 + <base>WORKSTN_SELECTIVE_RESTORE</base>
626 + <trans>Workstation selective file restore</trans>
627 + </entry>
628 + <entry>
629 + <base>ALL_BACKUPS</base>
630 + <trans>All backups</trans>
631 + </entry>
632 + <entry>
633 + <base>WORKSTN_SEL_REST_DESC</base>
634 + <trans>
635 + <![CDATA[
636 + This process will restore only specified files and directories. You must first choose
637 + the backup from which the files will be restored. If you don't know in which backup
638 + are the required files, you can select 'All backups' option. <br/><br/>
639 + The next panel will display available files and directories,
640 + so you can choose the ones to restore. To restrict the number of files and directories
641 + displayed in this panel, you have the option to give now a filtering expression,
642 + applied as a regular expression to the displayed names.<br/><br/>
643 + You have the responsability <b>not to restore</b> files which could break the functioning
644 + of your server.<br/> <br/>Currently, files will be restored from :
645 + ]]>
646 + </trans>
647 + </entry>
648 + <entry>
649 + <base>BACKUP_CHOICE</base>
650 + <trans>Selecting files to display</trans>
651 + </entry>
652 + <entry>
653 + <base>SELECT_DATE_BEFORE</base>
654 + <trans>Restore most recent before</trans>
655 + </entry>
656 + <entry>
657 + <base>FILTER_EXPRESSION</base>
658 + <trans>Names filtered by</trans>
659 + </entry>
660 + <entry>
661 + <base>READ_COMPLETE</base>
662 + <trans>
663 + <![CDATA[
664 + You can choose all the directories and files you want to restore in the displayed list
665 + (use ctrl or shift for multiple selection). <br/> <b>Warning :</b> If you select a directory,
666 + all contained files and directories will be restored.<p/>
667 + By default the most recent version of selected files is restored, but if you specify a date
668 + in the format <i>[ [ [yyyy/]mm/]dd-]hh:mm[:ss]</i> the process
669 + will restore only the most recent version modified <b>before the given date</b>.
670 + ]]>
671 + </trans>
672 + </entry>
673 + <entry>
674 + <base>ERR_INVALID_SELDATE</base>
675 + <trans>Date format is invalid, must be [ [ [yyyy/]mm/]dd-]hh:mm[:ss]. ie: 2005/12/31-08:23:32 or
676 + 10-08:32 or 08:32</trans>
677 + </entry>
678 + <entry>
679 + <base>SELECT_FILES_TO_RESTORE</base>
680 + <trans>Select files to restore</trans>
681 + </entry>
682 + <entry>
683 + <base>ERR_WHILE_UNMOUNTING</base>
684 + <trans>Error occurs when unmounting distant share</trans>
685 + </entry>
686 + <entry>
687 + <base>ERR_DAR_CATALOG</base>
688 + <trans>Error when using Dar catalog</trans>
689 + </entry>
690 + <entry>
691 + <base>COMPRESSION_LEVEL</base>
692 + <trans>Backup compression level [0-9]</trans>
693 + </entry>
694 + <entry>
695 + <base>FULL_ONLY_ON</base>
696 + <trans>Full backup is allowed on</trans>
697 + </entry>
698 + <entry>
699 + <base>ERR_INVALID_COMPRESSION</base>
700 + <trans>Compression level must be set between 0 (no compression) and 7 (maximum compression)</trans>
701 + </entry>
702 + <entry>
703 + <base>DOW</base>
704 + <trans>Sunday Monday Tuesday Wednesday Thursday Friday Saturday Everyday</trans>
705 + </entry>
706 + <entry>
707 + <base>CONFIGURATION_TO_BE_DONE</base>
708 + <trans>You must before execute Workstation backup configuration option</trans>
709 + </entry>
710 + <entry>
711 + <base>WORKSTN_BACKUP_DESC</base>
712 + <trans>
713 + <![CDATA[
714 + <p>This panel displays the present workstation backup configuration. You can
715 + change it in this panel and the next one.</p><p/>
716 + ]]>
717 + </trans>
718 + </entry>
719 + <entry>
720 + <base>WORKSTN_BACKUP_NOT_CONFIGURED</base>
721 + <trans>
722 + <![CDATA[
723 + <p>Presently, workstation backup is not configured. You can set this configuration
724 + with this panel and the next one.</p><p/>
725 + ]]>
726 + </trans>
727 + </entry>
728 + <entry>
729 + <base>WORKSTN_BACKUP_ENABLED</base>
730 + <trans>Backup is </trans>
731 + </entry>
732 + <entry>
733 + <base>WORKSTN_BACKUP_USB</base>
734 + <trans>Backup is made on local USB disk</trans>
735 + </entry>
736 + <entry>
737 + <base>WORKSTN_BACKUP_HOST</base>
738 + <trans>Backup is made on LAN workstation </trans>
739 + </entry>
740 + <entry>
741 + <base>WORKSTN_BACKUP_VFSTYPE</base>
742 + <trans> via </trans>
743 + </entry>
744 + <entry>
745 + <base>WORKSTN_BACKUP_SHARE</base>
746 + <trans>Destination backup share folder is </trans>
747 + </entry>
748 + <entry>
749 + <base>WORKSTN_BACKUP_TOD</base>
750 + <trans>Daily backup occurs at </trans>
751 + </entry>
752 + <entry>
753 + <base>LOGIN</base>
754 + <trans>Login is </trans>
755 + </entry>
756 + <entry>
757 + <base>PASSWORD</base>
758 + <trans>Password is </trans>
759 + </entry>
760 + <entry>
761 + <base>WORKSTN_BACKUP_SETSNUM</base>
762 + <trans>Number of rotating backup sets is </trans>
763 + </entry>
764 + <entry>
765 + <base>WORKSTN_BACKUP_DAYSINSET</base>
766 + <trans>Number of daily backups contained in each set is </trans>
767 + </entry>
768 + <entry>
769 + <base>WORKSTN_BACKUP_COMPRESSION</base>
770 + <trans>Compression level (0-7) of backup is </trans>
771 + </entry>
772 + <entry>
773 + <base>WORKSTN_BACKUP_TIMEOUT</base>
774 + <trans>Each daily backup session is cleanly timed out after </trans>
775 + </entry>
776 + <entry>
777 + <base>WORKSTN_BACKUP_INCONLY_TIMEOUT</base>
778 + <trans>except full backups which are cleanly timed out after 24 hours</trans>
779 + </entry>
780 + <entry>
781 + <base>WORKSTN_FULL_BACKUP_EVERYDAY</base>
782 + <trans>Full backup sessions (new backup set) are allowed everyday</trans>
783 + </entry>
784 + <entry>
785 + <base>WORKSTN_FULL_BACKUP_DAY</base>
786 + <trans>Full backup session (new backup sets) is allowed only on</trans>
787 + </entry>
788 + <entry>
789 + <base>WORKSTATION_BACKUP_SETCONF</base>
790 + <trans>Create or modify workstation backup configuration</trans>
791 + </entry>
792 + <entry>
793 + <base>SELECT_VFS_TYPE</base>
794 + <trans>Select the type of share for backup destination</trans>
795 + </entry>
796 + <entry>
797 + <base>ERR_NO_USB_DISK</base>
798 + <trans>Error : No USB disk available. Please connect an USB disk or select another type of backup share.</trans>
799 + </entry>
800 + <entry>
801 + <base>NEXT</base>
802 + <trans>Next</trans>
803 + </entry>
804 </lexicon>
805 diff -Nur -x '*.orig' -x '*.rej' e-smith-backup-1.15.0/root/etc/e-smith/templates/etc/crontab/backupwk mezzanine_patched_e-smith-backup-1.15.0/root/etc/e-smith/templates/etc/crontab/backupwk
806 --- e-smith-backup-1.15.0/root/etc/e-smith/templates/etc/crontab/backupwk 1969-12-31 19:00:00.000000000 -0500
807 +++ mezzanine_patched_e-smith-backup-1.15.0/root/etc/e-smith/templates/etc/crontab/backupwk 2007-09-05 15:52:45.000000000 -0400
808 @@ -0,0 +1,30 @@
809 +{
810 +
811 + $OUT = '';
812 +
813 + my $status = $backupwk{status};
814 +
815 + if (defined $status && $status eq 'enabled')
816 + {
817 + # configure backup time and reminder times from the configuration
818 + # database
819 +
820 + my $backupMin;
821 + my $backupHour;
822 +
823 + my $backupTime = $backupwk{BackupTime} || "1:00";
824 +
825 + ($backupHour, $backupMin) = split (":", $backupTime, -1);
826 +
827 + # remove leading zeros from minutes
828 +
829 + $backupMin =~ s/00/0/;
830 +
831 + $OUT .="$backupMin $backupHour * * * root"
832 + . " /sbin/e-smith/do_backupwk"
833 + }
834 + else
835 + {
836 + $OUT .= "# Workstation Backup task is disabled";
837 + }
838 +}
839 diff -Nur -x '*.orig' -x '*.rej' e-smith-backup-1.15.0/root/etc/e-smith/templates/etc/dar/DailyBackup.dcf/10compression mezzanine_patched_e-smith-backup-1.15.0/root/etc/e-smith/templates/etc/dar/DailyBackup.dcf/10compression
840 --- e-smith-backup-1.15.0/root/etc/e-smith/templates/etc/dar/DailyBackup.dcf/10compression 1969-12-31 19:00:00.000000000 -0500
841 +++ mezzanine_patched_e-smith-backup-1.15.0/root/etc/e-smith/templates/etc/dar/DailyBackup.dcf/10compression 2007-09-05 15:52:45.000000000 -0400
842 @@ -0,0 +1,3 @@
843 +{
844 +($backupwk{Compression} || '0') eq '0' ? "#Compression off\n" : "--bzip2=$backupwk{Compression}\n"
845 +}
846 \ No newline at end of file
847 diff -Nur -x '*.orig' -x '*.rej' e-smith-backup-1.15.0/root/etc/e-smith/templates/etc/dar/DailyBackup.dcf/20empty-dir mezzanine_patched_e-smith-backup-1.15.0/root/etc/e-smith/templates/etc/dar/DailyBackup.dcf/20empty-dir
848 --- e-smith-backup-1.15.0/root/etc/e-smith/templates/etc/dar/DailyBackup.dcf/20empty-dir 1969-12-31 19:00:00.000000000 -0500
849 +++ mezzanine_patched_e-smith-backup-1.15.0/root/etc/e-smith/templates/etc/dar/DailyBackup.dcf/20empty-dir 2007-09-05 15:52:45.000000000 -0400
850 @@ -0,0 +1 @@
851 +--empty-dir
852 diff -Nur -x '*.orig' -x '*.rej' e-smith-backup-1.15.0/root/etc/e-smith/templates/etc/dar/DailyBackup.dcf/30fs-root mezzanine_patched_e-smith-backup-1.15.0/root/etc/e-smith/templates/etc/dar/DailyBackup.dcf/30fs-root
853 --- e-smith-backup-1.15.0/root/etc/e-smith/templates/etc/dar/DailyBackup.dcf/30fs-root 1969-12-31 19:00:00.000000000 -0500
854 +++ mezzanine_patched_e-smith-backup-1.15.0/root/etc/e-smith/templates/etc/dar/DailyBackup.dcf/30fs-root 2007-09-05 15:52:45.000000000 -0400
855 @@ -0,0 +1 @@
856 +--fs-root /
857 diff -Nur -x '*.orig' -x '*.rej' e-smith-backup-1.15.0/root/etc/e-smith/templates/etc/dar/DailyBackup.dcf/40go-into mezzanine_patched_e-smith-backup-1.15.0/root/etc/e-smith/templates/etc/dar/DailyBackup.dcf/40go-into
858 --- e-smith-backup-1.15.0/root/etc/e-smith/templates/etc/dar/DailyBackup.dcf/40go-into 1969-12-31 19:00:00.000000000 -0500
859 +++ mezzanine_patched_e-smith-backup-1.15.0/root/etc/e-smith/templates/etc/dar/DailyBackup.dcf/40go-into 2007-09-05 15:52:45.000000000 -0400
860 @@ -0,0 +1,13 @@
861 +--go-into etc/e-smith/templates-custom
862 +--go-into etc/e-smith/templates-user-custom
863 +--go-into etc/group
864 +--go-into etc/gshadow
865 +--go-into etc/passwd
866 +--go-into etc/samba/secrets.tdb
867 +--go-into etc/samba/smbpasswd
868 +--go-into etc/shadow
869 +--go-into etc/smbpasswd
870 +--go-into etc/ssh
871 +--go-into etc/sudoers
872 +--go-into home/e-smith
873 +--go-into root
874 diff -Nur -x '*.orig' -x '*.rej' e-smith-backup-1.15.0/root/etc/e-smith/templates/etc/dar/DailyBackup.dcf/50exclude mezzanine_patched_e-smith-backup-1.15.0/root/etc/e-smith/templates/etc/dar/DailyBackup.dcf/50exclude
875 --- e-smith-backup-1.15.0/root/etc/e-smith/templates/etc/dar/DailyBackup.dcf/50exclude 1969-12-31 19:00:00.000000000 -0500
876 +++ mezzanine_patched_e-smith-backup-1.15.0/root/etc/e-smith/templates/etc/dar/DailyBackup.dcf/50exclude 2007-09-05 15:52:45.000000000 -0400
877 @@ -0,0 +1 @@
878 +--exclude "*.dar"
879 diff -Nur -x '*.orig' -x '*.rej' e-smith-backup-1.15.0/root/etc/e-smith/templates/etc/dar/DailyBackup.dcf/60exclude-compression mezzanine_patched_e-smith-backup-1.15.0/root/etc/e-smith/templates/etc/dar/DailyBackup.dcf/60exclude-compression
880 --- e-smith-backup-1.15.0/root/etc/e-smith/templates/etc/dar/DailyBackup.dcf/60exclude-compression 1969-12-31 19:00:00.000000000 -0500
881 +++ mezzanine_patched_e-smith-backup-1.15.0/root/etc/e-smith/templates/etc/dar/DailyBackup.dcf/60exclude-compression 2007-09-05 15:52:45.000000000 -0400
882 @@ -0,0 +1,29 @@
883 +{
884 +($backupwk{Compression} || '0') eq '0' ? "#Compression off\n" :
885 +'--exclude-compression "*.mp3"
886 +--exclude-compression "*.avi"
887 +--exclude-compression "*.mpg"
888 +--exclude-compression "*.mpeg"
889 +--exclude-compression "*.divx"
890 +--exclude-compression "*.rm"
891 +--exclude-compression "*.wmv"
892 +--exclude-compression "*.wma"
893 +--exclude-compression "*.asf"
894 +--exclude-compression "*.ra"
895 +--exclude-compression "*.gif"
896 +--exclude-compression "*.jpg"
897 +--exclude-compression "*.jpeg"
898 +--exclude-compression "*.png"
899 +--exclude-compression "*.zip"
900 +--exclude-compression "*.dar"
901 +--exclude-compression "*.tgz"
902 +--exclude-compression "*.gzip"
903 +--exclude-compression "*.bzip"
904 +--exclude-compression "*.bzip2"
905 +--exclude-compression "*.rar"
906 +--exclude-compression "*.gz"
907 +--exclude-compression "*.rpm"
908 +--exclude-compression "*.iso"
909 +--exclude-compression "*.bz2"
910 +'
911 +}
912 \ No newline at end of file
913 diff -Nur -x '*.orig' -x '*.rej' e-smith-backup-1.15.0/root/etc/e-smith/templates/etc/dar/DailyBackup.dcf/70noconf mezzanine_patched_e-smith-backup-1.15.0/root/etc/e-smith/templates/etc/dar/DailyBackup.dcf/70noconf
914 --- e-smith-backup-1.15.0/root/etc/e-smith/templates/etc/dar/DailyBackup.dcf/70noconf 1969-12-31 19:00:00.000000000 -0500
915 +++ mezzanine_patched_e-smith-backup-1.15.0/root/etc/e-smith/templates/etc/dar/DailyBackup.dcf/70noconf 2007-09-05 15:52:45.000000000 -0400
916 @@ -0,0 +1 @@
917 +--noconf
918 diff -Nur -x '*.orig' -x '*.rej' e-smith-backup-1.15.0/root/etc/e-smith/templates/etc/dar/DailyBackup.dcf/80no-warn mezzanine_patched_e-smith-backup-1.15.0/root/etc/e-smith/templates/etc/dar/DailyBackup.dcf/80no-warn
919 --- e-smith-backup-1.15.0/root/etc/e-smith/templates/etc/dar/DailyBackup.dcf/80no-warn 1969-12-31 19:00:00.000000000 -0500
920 +++ mezzanine_patched_e-smith-backup-1.15.0/root/etc/e-smith/templates/etc/dar/DailyBackup.dcf/80no-warn 2007-09-05 15:52:45.000000000 -0400
921 @@ -0,0 +1 @@
922 +--no-warn
923 diff -Nur -x '*.orig' -x '*.rej' e-smith-backup-1.15.0/root/etc/e-smith/templates/etc/dar/DailyBackup.dcf/90slice mezzanine_patched_e-smith-backup-1.15.0/root/etc/e-smith/templates/etc/dar/DailyBackup.dcf/90slice
924 --- e-smith-backup-1.15.0/root/etc/e-smith/templates/etc/dar/DailyBackup.dcf/90slice 1969-12-31 19:00:00.000000000 -0500
925 +++ mezzanine_patched_e-smith-backup-1.15.0/root/etc/e-smith/templates/etc/dar/DailyBackup.dcf/90slice 2007-09-05 15:52:45.000000000 -0400
926 @@ -0,0 +1,3 @@
927 +{
928 +($backupwk{Slice} || '700M') eq '700M' ? "--slice 700M\n" : "--slice $backupwk{Slice}\n"
929 +}
930 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
931 --- e-smith-backup-1.15.0/root/etc/e-smith/web/functions/backup 2007-09-05 15:45:52.000000000 -0400
932 +++ mezzanine_patched_e-smith-backup-1.15.0/root/etc/e-smith/web/functions/backup 2007-09-05 15:52:45.000000000 -0400
933 @@ -31,6 +31,9 @@
934 use esmith::cgi;
935 use esmith::util;
936 use esmith::lockfile;
937 +use File::Find;
938 +
939 +$File::Find::dont_use_nlink = 1; # fix for Windows shares
940
941 my $fm = esmith::FormMagick->new();
942
943 @@ -90,6 +93,30 @@
944 {
945 performTapeRestore ($q);
946 }
947 +elsif ($q->param ('state') eq "workstn-configure")
948 +{
949 + WorkstnBackupConfig1($q);
950 +}
951 +elsif ($q->param ('state') eq "workstn-configure1")
952 +{
953 + updateWorkstnBackupConfig($q);
954 +}
955 +elsif ($q->param ('state') eq "workstn-verify")
956 +{
957 + performWorkstnVerify($q);
958 +}
959 +elsif ($q->param ('state') eq "workstn-restore")
960 +{
961 + performWorkstnRestore ($q);
962 +}
963 +elsif ($q->param ('state') eq "workstn-sel-restore")
964 +{
965 + performWorkstnSelRestore ($q);
966 +}
967 +elsif ($q->param ('state') eq "workstn-sel-restore2")
968 +{
969 + performWorkstnSelRestore2 ($q);
970 +}
971 else
972 {
973 esmith::cgi::genStateError ($q, undef);
974 @@ -184,12 +211,34 @@
975 print $q->p($fm->localise('TAPE_BACKUPS_DISABLED')),"\n";
976 }
977
978 + my $backupwk_status = $conf->get('backupwk');
979 + if ($backupwk_status)
980 + {
981 + $backupwk_status = $backupwk_status->prop('status');
982 + }
983 +
984 + if (defined $backupwk_status && $backupwk_status eq "enabled")
985 + {
986 + my $backupwkTime = $conf->get('backupwk')->prop('BackupTime');
987 +
988 + print $q->p ($fm->localise('WORKSTN_BACKUPS_ENABLED'),
989 + $fm->localise('WKBACKUPS_RUN_AT'),$q->b($backupwkTime));
990 + }
991 + else
992 + {
993 + print $q->p($fm->localise('WORKSTN_BACKUPS_DISABLED'));
994 + }
995 +
996 my %labels = (
997 "desktop-backup" => $fm->localise('DESKTOP_BACKUP'),
998 "desktop-restore" => $fm->localise('DESKTOP_RESTORE'),
999 "desktop-verify" => $fm->localise('DESKTOP_VERIFY'),
1000 "tape-configure" => $fm->localise('TAPE_CONFIGURE'),
1001 "tape-restore" => $fm->localise('TAPE_RESTORE'),
1002 + "workstn-configure" => $fm->localise('WORKSTN_CONFIGURE'),
1003 + "workstn-verify" => $fm->localise('WORKSTN_VERIFY'),
1004 + "workstn-restore" => $fm->localise('WORKSTN_RESTORE'),
1005 + "workstn-sel-restore" => $fm->localise('WORKSTN_SEL_RESTORE'),
1006 );
1007
1008 my @labels = (
1009 @@ -198,6 +247,10 @@
1010 'desktop-verify',
1011 'tape-configure',
1012 'tape-restore',
1013 + 'workstn-configure',
1014 + 'workstn-verify',
1015 + 'workstn-restore',
1016 + 'workstn-sel-restore',
1017 );
1018
1019 my $default_action = 'desktop-backup';
1020 @@ -234,11 +287,13 @@
1021 %labels = (
1022 "refresh" => $fm->localise('REFRESH_THIS_DISPLAY'),
1023 "tape-configure" => $fm->localise('CONFIGURE_TAPE_BACKUP'),
1024 + "workstn-configure" => $fm->localise('CONFIGURE_WORKSTN_BACKUP'),
1025 );
1026
1027 @labels = (
1028 'refresh',
1029 'tape-configure',
1030 + 'workstn-configure',
1031 );
1032
1033 $default_action = 'refresh';
1034 @@ -381,6 +436,22 @@
1035 {
1036 tapeRestore();
1037 }
1038 + elsif ($function eq 'workstn-configure')
1039 + {
1040 + WorkstnBackupConfig ($q);
1041 + }
1042 + elsif ($function eq 'workstn-verify')
1043 + {
1044 + workstnVerify();
1045 + }
1046 + elsif ($function eq 'workstn-restore')
1047 + {
1048 + workstnRestore();
1049 + }
1050 + elsif ($function eq 'workstn-sel-restore')
1051 + {
1052 + workstnSelRestore();
1053 + }
1054 else
1055 {
1056 # Unknown function - refresh the screen anyway
1057 @@ -1291,166 +1362,1980 @@
1058 }
1059 }
1060
1061 -sub performReboot ()
1062 +sub WorkstnBackupConfig
1063 {
1064 - esmith::cgi::genHeaderNonCacheable ($q, undef,
1065 - $fm->localise('SERVER_REBOOT'));
1066 + my ($q) = @_;
1067 + my $backupwk_status;
1068 + my $enabledIncOnlyTimeout = "";
1069 + my $backupwkLogin = 'backup';
1070 + my $backupwkPassword = 'backup';
1071 + my $backupwkStation = 'host';
1072 + my $backupwkFolder = 'share';
1073 + my $setsNumber;
1074 + my $filesinset;
1075 + my $backupwkTime;
1076 + my $backupwkTimeout;
1077 + my $backupwkIncOnlyTimeout;
1078 + my $compression;
1079 + my $VFSType;
1080 + my $dof;
1081 + my @dlabels = split(' ', $fm->localise('DOW'));
1082 + my @VFST = ('smbfs', 'cifs', 'nfs', 'usb');
1083 + my %VFST = ('smbfs', 'smbfs', 'cifs', 'cifs', 'nfs', 'nfs', 'usb', 'local usb disk');
1084 +
1085 + # Obtain backup informations from configuration
1086 + my $rec = $conf->get('backupwk');
1087 + if ($rec)
1088 + {
1089 + $backupwkTime = $rec->prop('BackupTime') || '2:00';
1090 + $backupwkLogin = $rec->prop('Login') || 'backup';
1091 + $backupwkPassword = $rec->prop('Password') || 'backup';
1092 + $backupwkStation = $rec->prop('SmbHost') || 'host';
1093 + $backupwkFolder = $rec->prop('SmbShare') || 'share';
1094 + $setsNumber = $rec->prop('SetsMax') || '1';
1095 + $filesinset = $rec->prop('DaysInSet') || '1';
1096 + $backupwkTimeout = $rec->prop('Timeout') || '12';
1097 + $backupwkIncOnlyTimeout = $rec->prop('IncOnlyTimeout') || 'yes';
1098 + $compression = $rec->prop('Compression') || '0';
1099 + $dof = (defined $rec->prop('FullDay')) ? $rec->prop('FullDay') : '7';
1100 + $VFSType = $rec->prop('VFSType') || 'smbfs';
1101 + $backupwk_status = $rec->prop('status');
1102 + }
1103
1104 - print $q->p (
1105 - $q->b ($fm->localise('SERVER_WILL_REBOOT'))
1106 - );
1107 + esmith::cgi::genHeaderNonCacheable(
1108 + $q, undef, $fm->localise('CONFIGURE_WORKSTN_BACKUP'));
1109
1110 - esmith::cgi::genFooter($fm);
1111 + if ($rec) {
1112 + print $fm->localise('WORKSTN_BACKUP_DESC');
1113 + print $fm->localise('WORKSTN_BACKUP_ENABLED'), $q->b(' '.$backupwk_status), '.<br/>';
1114 + if ($VFSType eq 'usb') {
1115 + print $fm->localise('WORKSTN_BACKUP_USB'), '<br/>';
1116 + }
1117 + else {
1118 + print $fm->localise('WORKSTN_BACKUP_HOST'), ' ', $backupwkStation;
1119 + print ' ', $fm->localise('WORKSTN_BACKUP_VFSTYPE'), ' ', $VFSType, '<br/>';
1120 + }
1121 + print $fm->localise('WORKSTN_BACKUP_SHARE'), ' ', $backupwkFolder, '<br/>';
1122 + if (($VFSType eq 'smbfs') || ($VFSType eq 'cifs')) {
1123 + print $fm->localise('LOGIN'), ' ', $backupwkLogin, '<br/>';
1124 + print $fm->localise('PASSWORD'), ' ', $backupwkPassword, '<br/>';
1125 + }
1126 + print $fm->localise('WORKSTN_BACKUP_SETSNUM'), ' ', $setsNumber, '<br/>';
1127 + print $fm->localise('WORKSTN_BACKUP_DAYSINSET'), ' ', $filesinset, '<br/>';
1128 + print $fm->localise('WORKSTN_BACKUP_COMPRESSION'), ' ', $compression, '<br/>';
1129 + print $fm->localise('WORKSTN_BACKUP_TOD'), ' ', $backupwkTime, '<br/>';
1130 + print $fm->localise('WORKSTN_BACKUP_TIMEOUT'), ' ', $backupwkTimeout, 'h ';
1131 + if ( $backupwkIncOnlyTimeout eq 'yes' ) {print $fm->localise('WORKSTN_BACKUP_INCONLY_TIMEOUT')}
1132 + print '<br/>';
1133 + if ( $dof eq '7' ) {
1134 + print $fm->localise('WORKSTN_FULL_BACKUP_EVERYDAY', '<br/>');
1135 + }
1136 + else {
1137 + print $fm->localise('WORKSTN_FULL_BACKUP_DAY'), ' ', $dlabels[$dof], '<br/>';
1138 + }
1139 + }
1140 + else { print $fm->localise('WORKSTN_BACKUP_NOT_CONFIGURED'), '<br/>' }
1141
1142 - esmith::util::backgroundCommand(
1143 - 5,
1144 - "/sbin/e-smith/signal-event",
1145 - "reboot"
1146 + print $q->startform(
1147 + -method => 'POST',
1148 + -action => $q->url (-absolute => 1)
1149 );
1150 -}
1151
1152 -sub CalculateSizes ()
1153 -{
1154 - #------------------------------------------------------------
1155 - # figure out the size of the tar file.
1156 - #------------------------------------------------------------
1157 + print $q->start_table ({-class => "sme-noborders"});
1158
1159 - my $tarsize = 0;
1160 + print $q->Tr($q->td($q->h3 ($fm->localise('WORKSTATION_BACKUP_SETCONF'))));
1161
1162 - # It takes way too much time to do a du on /home/e-smith. So we'll
1163 - # estimate the current size.
1164 - # We do this by checking the quota used by each user on the system.
1165
1166 - use Quota;
1167 - use esmith::AccountsDB;
1168 - my $accounts = esmith::AccountsDB->open;
1169 + print $q->Tr(
1170 + esmith::cgi::genCell(
1171 + $q,
1172 + $fm->localise('SELECT_VFS_TYPE')
1173 + ),
1174
1175 - # Get a $dev value appropriate for use in Quota::query call.
1176 - my $dev = Quota::getqcarg("/home/e-smith/files");
1177 + esmith::cgi::genCell ($q, $q->popup_menu (-name => 'VFSType',
1178 + -values => [ @VFST ],
1179 + -labels => \%VFST,
1180 + -default => $VFSType)));
1181
1182 - foreach my $user ($accounts->users())
1183 + print "</table>\n";
1184 +
1185 + print $q->start_table ({width => "100%", -class => "sme-noborders"});
1186 + print $q->Tr($q->th({-class => "sme-layout"},
1187 + $q->submit(
1188 + -name => 'action',
1189 + -value => $fm->localise('NEXT')
1190 + )
1191 + )
1192 + );
1193 +
1194 + print $q->hidden(
1195 + -name => 'state',
1196 + -override => 1,
1197 + -default => 'workstn-configure'
1198 + );
1199 + print '</table>';
1200 +
1201 + print $q->endform;
1202 +
1203 + esmith::cgi::genFooter ($q);
1204 + return;
1205 +}
1206 +
1207 +sub WorkstnBackupConfig1
1208 +{
1209 + my ($q) = @_;
1210 + my $enabledChk = "";
1211 + my $enabledIncOnlyTimeout = "";
1212 + my $backupwkAMPM = 'AM';
1213 + my $backupwkMin;
1214 + my $backupwkHour;
1215 + my $backupwkLogin = 'backup';
1216 + my $backupwkPassword = 'backup';
1217 + my $backupwkStation = 'host';
1218 + my $backupwkFolder = 'share';
1219 + my $setsNumber;
1220 + my $filesinset;
1221 + my $backupwkTimeout;
1222 + my $backupwkIncOnlyTimeout;
1223 + my $compression;
1224 + my $VFSType = $q->param ('VFSType');
1225 + my $dof;
1226 + my @usbdisks;
1227 + my %dlabels = ();
1228 + my @dlabels = split(' ', $fm->localise('DOW'));
1229 + my $i = 0;
1230 + foreach (@dlabels) {
1231 + $dlabels{$i} = $_;
1232 + $i++;
1233 + }
1234 +
1235 + # Obtain backup informations from configuration
1236 + my $rec = $conf->get('backupwk');
1237 + my $backupwkTime = '2:00';
1238 + if ($rec)
1239 {
1240 - my $name = $user->key;
1241 - my $uid = getpwnam($name);
1242 - unless ($uid)
1243 - {
1244 - warn ($fm->localise('NO_UID_FOR_NAME').$name."\n");
1245 - # We shouldn't ever get here. If we do, we can't get
1246 - # the quota value for this user, so we just skip to
1247 - # the next one.
1248 - next;
1249 - }
1250 + $backupwkTime = $rec->prop('BackupTime') || '2:00';
1251 + $backupwkLogin = $rec->prop('Login') || 'backup';
1252 + $backupwkPassword = $rec->prop('Password') || 'backup';
1253 + $backupwkStation = $rec->prop('SmbHost') || 'host';
1254 + $backupwkFolder = $rec->prop('SmbShare') || 'share';
1255 + $setsNumber = $rec->prop('SetsMax') || '1';
1256 + $filesinset = $rec->prop('DaysInSet') || '1';
1257 + $backupwkTimeout = $rec->prop('Timeout') || '12';
1258 + $backupwkIncOnlyTimeout = $rec->prop('IncOnlyTimeout') || 'yes';
1259 + $compression = $rec->prop('Compression') || '0';
1260 + $dof = $rec->prop('FullDay') || '7';
1261 + }
1262
1263 - # Get current quota settings.
1264 - my ($blocks) = Quota::query($dev, $uid, 0);
1265 - $tarsize += $blocks;
1266 + ($backupwkHour, $backupwkMin) = split (':', $backupwkTime, -1);
1267 +
1268 + if ($backupwkHour > 12)
1269 + {
1270 + $backupwkHour -= 12;
1271 + $backupwkAMPM = 'PM';
1272 }
1273
1274 - # We add to this the size of root owned firectories, estimated using du.
1275 - # If this takes too long, then the admin only has his or
1276 - # herself to blame!
1277 + my $backupwk_status;
1278 + if ($rec)
1279 + {
1280 + $backupwk_status = $rec->prop('status');
1281 + }
1282
1283 - # Remove /home/e-smith from backup list, and make paths absolute
1284 - my @list = map { "/$_" } grep { !/home\/e-smith/ } @directories;
1285 - open(DU, "-|")
1286 - or exec '/usr/bin/du', '-s', @list;
1287 + if (defined $backupwk_status && $backupwk_status eq 'enabled')
1288 + {
1289 + $enabledChk = 'checked';
1290 + }
1291
1292 - while (<DU>)
1293 + if (defined $backupwkIncOnlyTimeout && $backupwkIncOnlyTimeout eq 'yes')
1294 {
1295 - my ($du) = split(/\s+/);
1296 - $tarsize += $du;
1297 + $enabledIncOnlyTimeout = 'checked';
1298 }
1299 - close DU;
1300
1301 - $tarsize = &showSize($tarsize);
1302 + esmith::cgi::genHeaderNonCacheable(
1303 + $q, undef, $fm->localise('CONFIGURE_WORKSTN_BACKUP'));
1304
1305 - #------------------------------------------------------------
1306 - # figure out the size of the dump files
1307 - #------------------------------------------------------------
1308 + if ( $VFSType eq 'usb' ) {
1309 + my @usbdisklist;
1310 + @usbdisklist = qx'ls /media';
1311 + for (@usbdisklist) {
1312 + next if /floppy/;
1313 + next if /cdrom/;
1314 + push @usbdisks, $_;
1315 + }
1316 + unless (scalar @usbdisks) {
1317 + esmith::cgi::genResult(
1318 + $fm->{cgi}, $fm->localise('ERR_NO_USB_DISK'));
1319 + return
1320 + }
1321 + }
1322
1323 - my $dumpsize = 0;
1324 + print $q->startform(
1325 + -method => 'POST',
1326 + -action => $q->url (-absolute => 1)
1327 + );
1328
1329 - open(DF, "-|")
1330 - or exec '/bin/df', '-P', '-t', 'ext3';
1331 + print $fm->localise('CONFIGURE_WORKSTN_BACKUP_DESC');
1332
1333 - while (<DF>)
1334 - {
1335 - next unless (/^\//);
1336 + print $q->start_table ({-class => "sme-noborders"});
1337
1338 - (undef, undef, my $s, undef) = split(/\s+/, $_);
1339 + print $q->Tr(
1340 + $q->td(
1341 + $fm->localise('ENABLE_WORKSTN_BACKUP')
1342 + . " <input type=\"checkbox\""
1343 + . " name=\"workstnbackup\""
1344 + . " $enabledChk"
1345 + . " value=\"on\">"
1346 + )
1347 + );
1348
1349 - $dumpsize += $s;
1350 - }
1351 + print $q->Tr($q->td($q->h3 ($fm->localise('WORKSTATION_BACKUP_DEST'))));
1352
1353 - # increase size by 10% to cope with dump overhead.
1354 + if ( $VFSType eq 'usb' ) {
1355 + print $q->Tr(
1356 + esmith::cgi::genCell(
1357 + $q,
1358 + $fm->localise('WORKSTN_NAME')
1359 + ),
1360
1361 - $dumpsize *= 1.1;
1362 + esmith::cgi::genCell ($q, 'localhost'),
1363 + );
1364 + }
1365 + else {
1366 + print $q->Tr(
1367 + esmith::cgi::genCell(
1368 + $q,
1369 + $fm->localise('WORKSTN_NAME')
1370 + ),
1371
1372 - close DF;
1373 + esmith::cgi::genCell ($q, $q->textfield (-name => 'backupwkStation',
1374 + -override => 1,
1375 + -default => $backupwkStation,
1376 + -size => 20)),
1377 + );
1378 + }
1379
1380 - $dumpsize = &showSize($dumpsize);
1381 + if ( $VFSType eq 'usb' ) {
1382 + print $q->Tr(
1383 + esmith::cgi::genCell(
1384 + $q,
1385 + $fm->localise('SHARED_FOLDER_NAME')
1386 + ),
1387 +
1388 + esmith::cgi::genCell ($q, $q->popup_menu (-name => 'backupwkFolder',
1389 + -values => [ @usbdisks ],
1390 + -default => $backupwkFolder,)),
1391 + );
1392 + }
1393 + else {
1394 + print $q->Tr(
1395 + esmith::cgi::genCell(
1396 + $q,
1397 + $fm->localise('SHARED_FOLDER_NAME')
1398 + ),
1399
1400 - #------------------------------------------------------------
1401 - # how much free space is in /tmp
1402 - #------------------------------------------------------------
1403 + esmith::cgi::genCell ($q, $q->textfield (-name => 'backupwkFolder',
1404 + -override => 1,
1405 + -default => $backupwkFolder,
1406 + -size => 20)),
1407 + );
1408 + }
1409
1410 - my $tmpfree = 0;
1411 - my $halffree = 0;
1412 + if ( ( $VFSType eq 'smbfs' ) || ( $VFSType eq 'cifs' ) ) {
1413 + print $q->Tr(
1414 + esmith::cgi::genCell(
1415 + $q,
1416 + $fm->localise('WORKSTN_LOGIN')
1417 + ),
1418
1419 - open(DF, "-|")
1420 - or exec '/bin/df', '-P', '-t', 'ext3', '/tmp';
1421 + esmith::cgi::genCell ($q, $q->textfield (-name => 'backupwkLogin',
1422 + -override => 1,
1423 + -default => $backupwkLogin,
1424 + -size => 12)),
1425 + );
1426
1427 - while (<DF>)
1428 - {
1429 - next unless (/^\//);
1430 + print $q->Tr(
1431 + esmith::cgi::genCell(
1432 + $q,
1433 + $fm->localise('WORKSTN_PASSWORD')
1434 + ),
1435
1436 - (undef, undef, undef, my $s) = split(/\s+/, $_);
1437 + esmith::cgi::genCell ($q, $q->textfield (-name => 'backupwkPassword',
1438 + -override => 1,
1439 + -default => $backupwkPassword,
1440 + -size => 20)),
1441 + );
1442 + }
1443
1444 - $tmpfree += $s;
1445 - }
1446 + print '</table>';
1447
1448 - close DF;
1449 + print $q->table ({border => 0, cellspacing => 1, cellpadding => 4});
1450
1451 - $halffree = $tmpfree / 2;
1452 + print $q->Tr($q->td({-colspan=>4},$q->h3 ($fm->localise('WORKSTN_BACKUP_SETTINGS'))));
1453
1454 - $tmpfree = &showSize($tmpfree);
1455 - $halffree = &showSize($halffree);
1456 + print $q->Tr(
1457 + esmith::cgi::genCell(
1458 + $q,
1459 + $fm->localise('NUMBER_OF_SETS')
1460 + ),
1461
1462 - return ($tarsize, $dumpsize, $tmpfree, $halffree);
1463 -}
1464 + esmith::cgi::genCell ($q, $q->textfield (-name => 'setsNumber',
1465 + -override => 1,
1466 + -default => $setsNumber,
1467 + -size => 3)),
1468
1469 -sub showSize
1470 -{
1471 - # convert size to Mb or Gb or Tb :) Remember, df reports in kb.
1472 + esmith::cgi::genCell ($q, $fm->localise('NUMBER_OF_FILES_IN_SET')),
1473 + esmith::cgi::genCell ($q, $q->textfield (-name => 'filesinset',
1474 + -override => 1,
1475 + -default => $filesinset,
1476 + -size => 3))
1477 + );
1478
1479 - my $size = shift;
1480 + print $q->Tr(
1481 + esmith::cgi::genCell(
1482 + $q,
1483 + $fm->localise('WORKSTN_BACKUP_TIME')
1484 + ),
1485
1486 - my $Mb = 1024;
1487 - my $Gb = $Mb * $Mb;
1488 - my $Tb = $Mb * $Mb * $Mb;
1489 + esmith::cgi::genCell ($q, $q->textfield (-name => 'backupwkHour',
1490 + -override => 1,
1491 + -default => $backupwkHour,
1492 + -size => 2)),
1493
1494 - if ($size >= $Tb)
1495 - {
1496 - $size /= $Tb;
1497 - $size = int($size) . "Tb";
1498 - }
1499 - elsif ($size >= $Gb)
1500 - {
1501 - $size /= $Gb;
1502 - $size = int($size) . "Gb";
1503 - }
1504 - elsif ($size >= $Mb)
1505 - {
1506 - $size /= $Mb;
1507 - $size = int($size) . "Mb";
1508 - }
1509 - else
1510 - {
1511 - $size .= "kb";
1512 - }
1513 + esmith::cgi::genCell ($q, $q->textfield (-name => 'backupwkMin',
1514 + -override => 1,
1515 + -default => $backupwkMin,
1516 + -size => 2)),
1517
1518 - return $size;
1519 -}
1520 + esmith::cgi::genCell ($q, $q->popup_menu (-name => 'backupwkAMPM',
1521 + -values => ['AM', 'PM'],
1522 + -default => $backupwkAMPM)));
1523 +
1524 + print $q->Tr(
1525 + esmith::cgi::genCell(
1526 + $q,
1527 + $fm->localise('WORKSTN_TIMEOUT')
1528 + ),
1529 +
1530 + esmith::cgi::genCell ($q, $q->textfield (-name => 'backupwkTimeout',
1531 + -override => 1,
1532 + -default => $backupwkTimeout,
1533 + -size => 2)),
1534 +
1535 + esmith::cgi::genCell(
1536 + $q,
1537 + $fm->localise('INC_ONLY_TIMEOUT')
1538 + ),
1539 +
1540 + esmith::cgi::genCell (
1541 + $q,
1542 + " <input type=\"checkbox\""
1543 + . " name=\"incOnlyTimeout\""
1544 + . " $enabledIncOnlyTimeout"
1545 + . " value=\"on\">"
1546 + ),
1547 + );
1548 +
1549 + print $q->Tr(
1550 + esmith::cgi::genCell(
1551 + $q,
1552 + $fm->localise('COMPRESSION_LEVEL')
1553 + ),
1554 +
1555 + esmith::cgi::genCell ($q, $q->textfield (-name => 'compression',
1556 + -override => 1,
1557 + -default => $compression,
1558 + -size => 1)),
1559 +
1560 + esmith::cgi::genCell(
1561 + $q,
1562 + $fm->localise('FULL_ONLY_ON')
1563 + ),
1564 +
1565 + esmith::cgi::genCell (
1566 + $q,
1567 + $q->popup_menu (
1568 + -name => 'dof',
1569 + -values => [ '7', '0', '1', '2', '3', '4', '5', '6' ],
1570 + -labels => \%dlabels,
1571 + -default => $dof))
1572 + );
1573 +
1574 + print "</table>\n";
1575 +
1576 + print $q->start_table ({width => "100%", -class => "sme-noborders"});
1577 + print $q->Tr($q->th({-class => "sme-layout"},
1578 + $q->submit(
1579 + -name => 'action',
1580 + -value => $fm->localise('UPDATE_CONF')
1581 + )
1582 + )
1583 + );
1584 +
1585 + print $q->hidden(
1586 + -name => 'state',
1587 + -override => 1,
1588 + -default => 'workstn-configure1'
1589 + );
1590 + print $q->hidden(
1591 + -name => 'VFSType',
1592 + -override => 1,
1593 + -default => $VFSType
1594 + );
1595 + print '</table>';
1596 +
1597 + print $q->endform;
1598 +
1599 + esmith::cgi::genFooter ($q);
1600 + return;
1601 +}
1602 +
1603 +sub updateWorkstnBackupConfig
1604 +{
1605 + my ($q) = @_;
1606 +
1607 + my $status = $q->param ('workstnbackup');
1608 + my $inconly = $q->param ('incOnlyTimeout');
1609 + my $dof = $q->param('dof');
1610 + my $ampm;
1611 + my $incOnlyTimeout;
1612 +
1613 + esmith::cgi::genHeaderNonCacheable(
1614 + $q,
1615 + undef, $fm->localise('UPDATING_WORKSTN_CONF')
1616 + );
1617 +
1618 + #--------------------------------------------------
1619 + # Untaint parameters and check for validity
1620 + #--------------------------------------------------
1621 +
1622 + my $VFSType = $q->param ('VFSType');
1623 +
1624 + my $backupwkStation = $q->param ('backupwkStation');
1625 + if ( $VFSType eq 'usb') { $backupwkStation = 'localhost' }
1626 + if ($backupwkStation =~ /^(.*)$/) {
1627 + $backupwkStation = $1;
1628 + } else {
1629 + $backupwkStation = "";
1630 + }
1631 + if ( $backupwkStation eq "" )
1632 + {
1633 + esmith::cgi::genResult(
1634 + $q, $fm->localise('ERR_INVALID_WORKSTN')
1635 + );
1636 + return;
1637 + }
1638 +
1639 + my $backupwkFolder = $q->param ('backupwkFolder');
1640 + if ( $VFSType eq 'usb' ) {
1641 + $backupwkFolder = 'media/' . $backupwkFolder;
1642 + }
1643 + if ($backupwkFolder =~ /^(.*)$/) {
1644 + $backupwkFolder = $1;
1645 + $backupwkFolder =~ s/^\//; # remove leading /
1646 + } else {
1647 + $backupwkFolder = "";
1648 + }
1649 + if ( $backupwkFolder eq "" )
1650 + {
1651 + esmith::cgi::genResult(
1652 + $q, $fm->localise('ERR_INVALID_FOLDER')
1653 + );
1654 + return;
1655 + }
1656 +
1657 + my $backupwkLogin = $q->param ('backupwkLogin');
1658 + if ($backupwkLogin =~ /^(.*)$/) {
1659 + $backupwkLogin = $1;
1660 + } else {
1661 + $backupwkLogin = "";
1662 + }
1663 + if ( ( $backupwkLogin eq "" ) && (( $VFSType eq 'smbfs' ) || ( $VFSType eq 'cifs' )) )
1664 + {
1665 + esmith::cgi::genResult(
1666 + $q, $fm->localise('ERR_INVALID_LOGIN')
1667 + );
1668 + return;
1669 + }
1670 +
1671 + my $backupwkPassword = $q->param ('backupwkPassword');
1672 + if ($backupwkPassword =~ /^(.*)$/) {
1673 + $backupwkPassword = $1;
1674 + } else {
1675 + $backupwkPassword = "";
1676 + }
1677 + if ( ( $backupwkPassword eq "" ) && (( $VFSType eq 'smbfs' ) || ( $VFSType eq 'cifs' )) )
1678 + {
1679 + esmith::cgi::genResult(
1680 + $q, $fm->localise('ERR_INVALID_PASSWORD')
1681 + );
1682 + return;
1683 + }
1684 +
1685 + my $setsNumber = $q->param ('setsNumber');
1686 + unless ( $setsNumber > 0 )
1687 + {
1688 + esmith::cgi::genResult(
1689 + $q, $fm->localise('ERR_INVALID_SETS_NUMBER')
1690 + );
1691 + return;
1692 + }
1693 +
1694 + my $filesinset = $q->param ('filesinset');
1695 + unless ( $filesinset > 0 )
1696 + {
1697 + esmith::cgi::genResult(
1698 + $q, $fm->localise('ERR_INVALID_FILES_IN_SET_NUMBER')
1699 + );
1700 + return;
1701 + }
1702 +
1703 + my $timeout = $q->param ('backupwkTimeout');
1704 + if (( $timeout eq '') || ( $timeout == 0 )) {$timeout = 24 }
1705 + if (( $timeout < 1 ) || ( $timeout > 24 ))
1706 + {
1707 + esmith::cgi::genResult(
1708 + $q, $fm->localise('ERR_INVALID_TIMEOUT')
1709 + );
1710 + return;
1711 + }
1712 +
1713 + if (defined $inconly && $inconly eq 'on')
1714 + {
1715 + $incOnlyTimeout = 'yes';
1716 + }
1717 + else
1718 + {
1719 + $incOnlyTimeout = 'no';
1720 + }
1721 +
1722 + my $compression = $q->param ('compression');
1723 + if (( $compression < 0 ) || ( $compression > 7 ))
1724 + {
1725 + esmith::cgi::genResult(
1726 + $q, $fm->localise('ERR_INVALID_COMPRESSION')
1727 + );
1728 + return;
1729 + }
1730 +
1731 + my $rec = $conf->get('backupwk');
1732 + unless (defined $rec)
1733 + {
1734 + $rec = $conf->new_record('backupwk', {type=>'service'});
1735 + }
1736 +
1737 + $rec->set_prop('SmbHost', $backupwkStation);
1738 + $rec->set_prop('SmbShare', $backupwkFolder);
1739 + $rec->set_prop('Login', $backupwkLogin);
1740 + $rec->set_prop('Password', $backupwkPassword);
1741 + $rec->set_prop('SetsMax', $setsNumber);
1742 + $rec->set_prop('DaysInSet', $filesinset);
1743 + $rec->set_prop('Timeout', $timeout);
1744 + $rec->set_prop('IncOnlyTimeout', $incOnlyTimeout);
1745 + $rec->set_prop('Compression', $compression);
1746 + $rec->set_prop('FullDay', $dof);
1747 + $rec->set_prop('VFSType', $VFSType);
1748 +
1749 + my $module = $rec->prop('Program');
1750 +
1751 + # The default workstation backup program is dar.
1752 +
1753 + unless (defined $module)
1754 + {
1755 + $module = 'dar';
1756 + }
1757 + elsif ($module eq '')
1758 + {
1759 + $module = 'dar';
1760 + }
1761 +
1762 + $rec->set_prop('Program', $module);
1763 +
1764 + if (defined $status && $status eq 'on')
1765 + {
1766 +
1767 + my $backupwkHour = $q->param ('backupwkHour');
1768 + if ($backupwkHour =~ /^(.*)$/) {
1769 + $backupwkHour = $1;
1770 + } else {
1771 + $backupwkHour = '12';
1772 + }
1773 + if (($backupwkHour < 0) || ($backupwkHour > 12))
1774 + {
1775 + esmith::cgi::genResult(
1776 + $q, $fm->localise('ERR_INVALID_HOUR').$backupwkHour.
1777 + $fm->localise('BETWEEN_0_AND_12')
1778 + );
1779 +
1780 + return;
1781 + }
1782 +
1783 + my $backupwkMin = $q->param ('backupwkMin');
1784 + if ($backupwkMin =~ /^(.*)$/) {
1785 + $backupwkMin = $1;
1786 + } else {
1787 + $backupwkMin = '0';
1788 + }
1789 + if (($backupwkMin < 0) || ($backupwkMin > 59))
1790 + {
1791 + esmith::cgi::genResult(
1792 + $q, $fm->localise('ERR_INVALID_MINUTE').$backupwkMin.
1793 + $fm->localise('BETWEEN_0_AND_59')
1794 + );
1795 +
1796 + return;
1797 + }
1798 +
1799 + $backupwkMin = sprintf("%02d", $backupwkMin);
1800 +
1801 + $ampm = $q->param ('backupwkAMPM');
1802 + if ($ampm =~ /^(.*)$/) {
1803 + $ampm = $1;
1804 + } else {
1805 + $ampm = 'AM';
1806 + }
1807 +
1808 + # convert to 24 hour time
1809 +
1810 + $backupwkHour = $backupwkHour % 12;
1811 + if ($ampm eq 'PM')
1812 + {
1813 + $backupwkHour = $backupwkHour + 12;
1814 + }
1815 +
1816 +
1817 + # variables passed validity checks, set configuration database values
1818 + my $old = $conf->get('UnsavedChanges')->value;
1819 +
1820 + $rec->set_prop('status', 'enabled');
1821 +
1822 + $rec->set_prop('BackupTime', "$backupwkHour:$backupwkMin");
1823 +
1824 + $conf->get('UnsavedChanges')->set_value($old);
1825 +
1826 + system("/sbin/e-smith/signal-event", "conf-backup") == 0
1827 + or die($fm->localise('ERR_CONF_BACKUP'),"\n");
1828 +
1829 + esmith::cgi::genResult(
1830 + $q, $fm->localise('SUCCESSFULLY_ENABLED_WORKSTN').$q->br().
1831 + $fm->localise('WITH_BACKUP_TIME')."$backupwkHour:$backupwkMin");
1832 + }
1833 + else
1834 + {
1835 + # set service to disabled
1836 + my $old = $conf->get('UnsavedChanges')->value;
1837 +
1838 + $rec->set_prop('status', 'disabled');
1839 + $conf->get('UnsavedChanges')->set_value($old);
1840 +
1841 + system("/sbin/e-smith/signal-event", "conf-backup") == 0
1842 + or die($fm->localise('ERR_CONF_BACKUP')."\n");
1843 +
1844 + esmith::cgi::genResult(
1845 + $q, $fm->localise('SUCCESSFULLY_DISABLED_WORKSTN')
1846 + );
1847 + }
1848 +
1849 + return;
1850 +}
1851 +
1852 +sub workstnVerify ()
1853 +{
1854 +
1855 + my $rec = $conf->get('backupwk');
1856 +
1857 + esmith::cgi::genHeaderNonCacheable ($q, undef,
1858 + $fm->localise('VERIFY_WORKSTN_BACKUP_FILE'));
1859 +
1860 + unless ($rec)
1861 + {
1862 + esmith::cgi::genResult(
1863 + $q, $fm->localise('CONFIGURATION_TO_BE_DONE'));
1864 + return;
1865 + }
1866 +
1867 + my %backupfiles = ();
1868 + my $mntdir = $rec->prop('MountDir') || '/mnt/smb';
1869 + my $mntbkdir;
1870 + my $mounted;
1871 + my $key;
1872 + my $id = $rec->prop('Id') || $conf->get('SystemName')->value . "." . $conf->get('DomainName')->value;
1873 + my $smbhost = $rec->prop('SmbHost');
1874 + my $smbshare = $rec->prop('SmbShare');
1875 + my $VFSType = $rec->prop('VFSType') || 'smbfs';
1876 + my $err;
1877 +
1878 + my $setbackuplist = sub {
1879 + if ( $_ =~ /\.dar/ ) {
1880 + my $dir = $File::Find::dir;
1881 + my $backupref;
1882 + $dir =~ s/$mntbkdir\///;
1883 + $_ =~ s/\..*\.dar//;
1884 + $backupref = $_;
1885 + $_ =~ s/.*-//;
1886 + @{$backupfiles{$_}}[0] = $dir;
1887 + @{$backupfiles{$_}}[1] = $backupref;
1888 + }
1889 + };
1890 +
1891 + # Mounting backup shared folder
1892 +
1893 + unless (-d $mntdir)
1894 + {
1895 + mkdir -p $mntdir;
1896 + }
1897 +
1898 + my $login = $rec->prop('Login') || 'backup';
1899 + my $password = $rec->prop('Password') || 'backup';
1900 +
1901 + if ( $err = dmount($smbhost,$smbshare,$mntdir,$login,$password,$VFSType) )
1902 + {
1903 + esmith::cgi::genResult(
1904 + $q, $fm->localise('ERR_MOUNTING_SMBSHARE') . "\n" . $err
1905 + );
1906 + return;
1907 + }
1908 + elsif ( $VFSType ne 'usb' ) {$mounted = 1}
1909 +
1910 + # Test if backup subdirectory for our server
1911 +
1912 + $mntbkdir = $mntdir . '/' . $id;
1913 + unless ( -d $mntbkdir)
1914 + {
1915 + if ($mounted) {
1916 + system("/bin/umount $mntdir") == 0
1917 + or die($fm->localise('ERR_WHILE_UNMOUNTING'),"\n");
1918 + }
1919 + esmith::cgi::genResult(
1920 + $q, $fm->localise('ERR_NO_HOST_DIR'.$id)
1921 + );
1922 + return;
1923 + }
1924 +
1925 + # Finding existing backups
1926 +
1927 + find { wanted => \&$setbackuplist, untaint => 1 }, $mntbkdir ;
1928 +
1929 + my %blabels = ();
1930 + my @blabels;
1931 + my $backups = 0;
1932 +
1933 + foreach $key (sort keys %backupfiles) {
1934 + my $labkey = $mntbkdir . '/' . $backupfiles{$key}[0] . '/' . $backupfiles{$key}[1];
1935 + $blabels{$labkey} = $backupfiles{$key}[1] . " (" . $backupfiles{$key}[0] . ")";
1936 + $backups = push @blabels, $labkey;
1937 + }
1938 +
1939 + if ($mounted) {
1940 + system("/bin/umount $mntdir") == 0
1941 + or die($fm->localise('ERR_WHILE_UNMOUNTING'),"\n");
1942 + }
1943 +
1944 + # Stops here if no backups
1945 +
1946 + if ( $backups == 0 ) {
1947 + esmith::cgi::genResult(
1948 + $q, $fm->localise('NO_BACKUPS_TO_RESTORE'));
1949 + return;
1950 + }
1951 +
1952 + print $q->p ($fm->localise('VERIFY_WORKSTN_BACKUP_DESC') . ' ' . "$smbhost/$smbshare/$id");
1953 + print $q->p;
1954 +
1955 + print $q->start_multipart_form(
1956 + -method => 'POST',
1957 + -action => $q->url (-absolute => 1)
1958 + );
1959 +
1960 + print $q->table ({border => 0, cellspacing => 0, cellpadding => 4},
1961 +
1962 + esmith::cgi::genWidgetRow(
1963 + $q,
1964 + $fm->localise('SELECT_BACKUP_FILE'),
1965 + $q->popup_menu (
1966 + -name => 'backupset',
1967 + -values => [ @blabels ],
1968 + -labels => \%blabels
1969 + )
1970 + )
1971 + );
1972 +
1973 + print $q->table ({width => "100%", -class => "sme-noborders"},
1974 + esmith::cgi::genButtonRow(
1975 + $q,
1976 + $q->submit(
1977 + -name => 'action',
1978 + -value => $fm->localise('VERIFY')
1979 + )
1980 + )
1981 + ),"\n";
1982 +
1983 + print $q->hidden(
1984 + -name => 'state',
1985 + -override => 1,
1986 + -default => 'workstn-verify'
1987 + );
1988 +
1989 + print $q->endform;
1990 +
1991 + esmith::cgi::genFooter ($q);
1992 +}
1993 +
1994 +sub performWorkstnVerify
1995 +{
1996 + my ($q) = @_;
1997 +
1998 + my $backupwkrec = $conf->get('backupwk');
1999 + my $smbhost = $backupwkrec->prop('SmbHost');
2000 + my $smbshare = $backupwkrec->prop('SmbShare');
2001 + my $login = $backupwkrec->prop('Login');
2002 + my $password = $backupwkrec->prop('Password');
2003 + my $mntdir = $backupwkrec->prop('MountDir') || '/mnt/smb';
2004 + my $mounted;
2005 + my $key;
2006 + my $id = $backupwkrec->prop('Id') || $conf->get('SystemName')->value . "." . $conf->get('DomainName')->value;
2007 + my $err;
2008 + my $VFSType = $backupwkrec->prop('VFSType') || 'smbfs';
2009 +
2010 + # Mounting backup shared folder
2011 +
2012 + if ( $err = dmount($smbhost,$smbshare,$mntdir,$login,$password,$VFSType) )
2013 + {
2014 + esmith::cgi::genResult(
2015 + $q, $fm->localise('ERR_MOUNTING_SMBSHARE') . "\n" . $err
2016 + );
2017 + return;
2018 + }
2019 + elsif ( $VFSType ne 'usb' ) {$mounted = 1}
2020 +
2021 + # Test if backup subdirectory for our server
2022 +
2023 + my $mntbkdir = $mntdir . "/$id";
2024 + unless ( -d $mntbkdir)
2025 + {
2026 + if ($mounted) {
2027 + system("/bin/umount $mntdir") == 0
2028 + or die($fm->localise('ERR_WHILE_UNMOUNTING'),"\n");
2029 + }
2030 + esmith::cgi::genResult(
2031 + $q, $fm->localise('ERR_NO_HOST_DIR'.$id)
2032 + );
2033 + return;
2034 + }
2035 +
2036 + my $backupkey = $q->param ('backupset');
2037 + if ($backupkey =~ /^(.*)$/) {
2038 + $backupkey = $1;
2039 + }
2040 + else {
2041 + if ($mounted) {
2042 + system("/bin/umount $mntdir") == 0
2043 + or die($fm->localise('ERR_WHILE_UNMOUNTING'),"\n");
2044 + }
2045 + die('Unsecure data : ' . $backupkey);
2046 + }
2047 +
2048 + if (open(RD, "-|"))
2049 + {
2050 + esmith::cgi::genHeaderNonCacheable ($q,
2051 + undef, $fm->localise('VERIFY_WORKSTN_BACKUP_FILE'));
2052 +
2053 + print $q->p($fm->localise('FILES_IN_BACKUP'));
2054 +
2055 + print '<UL>';
2056 +
2057 + my $complete = 0;
2058 + while (<RD>)
2059 + {
2060 + $complete++ if /etc\/smbpasswd$/;
2061 + $complete++ if /etc\/samba\/smbpasswd$/; # >6.0 base
2062 + print "<li>$_</li>\n";
2063 + }
2064 +
2065 + print '</UL>';
2066 + my $status = close RD ?
2067 + ($complete ?
2068 + $fm->localise('VERIFY_COMPLETE') :
2069 + $fm->localise('BACKUP_FILE_INCOMPLETE'))
2070 + : ($fm->localise('ERROR_READING_FILE').' : '.$backupkey);
2071 + print $q->p ($q->b ($status));
2072 +
2073 + esmith::cgi::genFooter ($q);
2074 +
2075 + }
2076 + else
2077 + {
2078 + select(STDOUT);
2079 + $| = 1;
2080 +
2081 + system ("/usr/bin/dar --list $backupkey --noconf") == 0
2082 + or die ($fm->localise('ERR_EXTRACT')." : ".$!);
2083 +
2084 + if ($mounted) {
2085 + system("/bin/umount $mntdir") == 0
2086 + or die($fm->localise('ERR_WHILE_UNMOUNTING'),"\n");
2087 + }
2088 + exit(0);
2089 + }
2090 +
2091 + return;
2092 +}
2093 +
2094 +sub workstnRestore ()
2095 +{
2096 +
2097 + my $rec = $conf->get('backupwk');
2098 +
2099 + esmith::cgi::genHeaderNonCacheable(
2100 + $q, undef, $fm->localise('RESTORE_CONF_FROM_WORKSTN'));
2101 +
2102 + unless ($rec)
2103 + {
2104 + esmith::cgi::genResult(
2105 + $q, $fm->localise('CONFIGURATION_TO_BE_DONE'));
2106 + return;
2107 + }
2108 +
2109 + my $mntdir = $rec->prop('MountDir') || '/mnt/smb';
2110 + my $mntbkdir;
2111 + my $mounted;
2112 + my %backupfiles = ();
2113 + my $key;
2114 + my $id = $rec->prop('Id') || $conf->get('SystemName')->value . "." . $conf->get('DomainName')->value;
2115 + my $VFSType = $rec->prop('VFSType') || 'smbfs';
2116 + my $smbhost = $rec->prop('SmbHost');
2117 + my $smbshare = $rec->prop('SmbShare');
2118 + my $err;
2119 +
2120 + my $setbackupflist = sub {
2121 + if ( $_ =~ /\.dar/ ) {
2122 + my $dir = $File::Find::dir;
2123 + my $backupref;
2124 + $dir =~ s/$mntbkdir\///;
2125 + $_ =~ s/\..*\.dar//;
2126 + $backupref = $_;
2127 + $_ =~ s/.*-//;
2128 + @{$backupfiles{$_}}[0] = $dir;
2129 + @{$backupfiles{$_}}[1] = $backupref;
2130 + }
2131 + };
2132 +
2133 + # Mounting backup shared folder
2134 +
2135 + unless (-d $mntdir)
2136 + {
2137 + mkdir -p $mntdir;
2138 + }
2139 +
2140 + my $login = $rec->prop('Login') || 'backup';
2141 + my $password = $rec->prop('Password') || 'backup';
2142 +
2143 + if ( $err = dmount($smbhost,$smbshare,$mntdir,$login,$password,$VFSType) )
2144 + {
2145 + esmith::cgi::genResult(
2146 + $q, $fm->localise('ERR_MOUNTING_SMBSHARE') . "\n" . $err
2147 + );
2148 + return;
2149 + }
2150 + elsif ( $VFSType ne 'usb' ) {$mounted = 1}
2151 +
2152 + # Test if backup subdirectory for our server
2153 +
2154 + $mntbkdir = $mntdir . "/$id";
2155 + unless ( -d $mntbkdir)
2156 + {
2157 + if ($mounted) {
2158 + system("/bin/umount $mntdir") == 0
2159 + or die($fm->localise('ERR_WHILE_UNMOUNTING'),"\n");
2160 + }
2161 + esmith::cgi::genResult(
2162 + $q, $fm->localise('ERR_NO_HOST_DIR'.$id)
2163 + );
2164 + return;
2165 + }
2166 +
2167 + # Finding existing backups
2168 +
2169 + find { wanted => \&$setbackupflist, untaint => 1 }, $mntbkdir ;
2170 +
2171 + my %blabels = ();
2172 + my @blabels;
2173 + my $backups = 0;
2174 +
2175 + foreach $key (sort keys %backupfiles) {
2176 + my $labkey = $mntbkdir . '/' . $backupfiles{$key}[0] . '/' . $backupfiles{$key}[1];
2177 + $blabels{$labkey} = $backupfiles{$key}[1] . ' (' . $backupfiles{$key}[0] . ')';
2178 + $backups = push @blabels, $labkey;
2179 + }
2180 +
2181 + if ($mounted) {
2182 + system("/bin/umount $mntdir") == 0
2183 + or die($fm->localise('ERR_WHILE_UNMOUNTING'),"\n");
2184 + }
2185 +
2186 + if ( $backups == 0 ) {
2187 + esmith::cgi::genResult(
2188 + $q, $fm->localise('NO_BACKUPS_TO_RESTORE'));
2189 + return;
2190 + }
2191 +
2192 + print $q->p ($fm->localise('RESTORE_CONF_FROM_WORKSTN_DESC') . ' ' . "$smbhost/$smbshare/$id");
2193 + print $q->p;
2194 +
2195 + print $q->start_multipart_form(
2196 + -method => 'POST',
2197 + -action => $q->url (-absolute => 1)
2198 + );
2199 +
2200 + print $q->table ( {border => 0, cellspacing => 0, cellpadding => 4},
2201 +
2202 + esmith::cgi::genWidgetRow(
2203 + $q,
2204 + $fm->localise('SELECT_BACKUP_FILE'),
2205 + $q->popup_menu (
2206 + -name => 'backuptorestore',
2207 + -values => [ @blabels ],
2208 + -labels => \%blabels
2209 + )
2210 + )
2211 + );
2212 +
2213 + print $q->table ( {width => "100%", -class => "sme-noborders"},
2214 + esmith::cgi::genButtonRow(
2215 + $q,
2216 + $q->submit(
2217 + -name => 'action',
2218 + -value => $fm->localise('RESTORE_FROM_WORKSTN')
2219 + )
2220 + )
2221 + );
2222 +
2223 + print $q->hidden(
2224 + -name => 'state',
2225 + -override => 1,
2226 + -default => 'workstn-restore'
2227 + );
2228 +
2229 + print $q->endform;
2230 +
2231 + esmith::cgi::genFooter ($q);
2232 +}
2233 +
2234 +sub performWorkstnRestore
2235 +{
2236 + my ($q) = @_;
2237 + my $restoreref = $q->param ('backuptorestore');
2238 + my $set = $restoreref;
2239 + $set =~ s/\/[^\/]*$//;
2240 + my %backupsetfiles = ();
2241 + my @restorefiles;
2242 +
2243 + my $backupsetlist = sub {
2244 + if ( $_ =~ /\.dar/ ) {
2245 + my $backupref = $File::Find::name;
2246 + $backupref =~ s/\.[0-9]+\.dar//;
2247 + $_ =~ s/\..*\.dar//;
2248 + $_ =~ s/.*-//;
2249 + $backupsetfiles{$_} = $backupref;
2250 + }
2251 + };
2252 +
2253 +
2254 + my $lock_file = "/var/lock/subsys/e-smith-restore";
2255 + my $file_handle = &esmith::lockfile::LockFileOrReturn($lock_file);
2256 +
2257 + unless ($file_handle)
2258 + {
2259 + esmith::cgi::genHeaderNonCacheable(
2260 + $q,
2261 + undef, $fm->localise('RESTORE_CANNOT_PROCEED')
2262 + );
2263 +
2264 + print $q->p (
2265 + $q->b ($fm->localise('ANOTHER_RESTORE_IN_PROGRESS')
2266 + )
2267 + );
2268 +
2269 + esmith::cgi::genFooter ($q);
2270 + return;
2271 + }
2272 +
2273 + # mounting backup shared folder
2274 +
2275 + my $backupwkrec = $conf->get('backupwk');
2276 + my $login = $backupwkrec->prop('Login');
2277 + my $password = $backupwkrec->prop('Password');
2278 + my $id = $backupwkrec->prop('Id') || $conf->get('SystemName')->value . "." . $conf->get('DomainName')->value;
2279 + my $mntdir = $backupwkrec->prop('MountDir') || '/mnt/smb';
2280 + my $mounted;
2281 + my $VFSType = $backupwkrec->prop('VFSType') || 'smbfs';
2282 + my $smbhost = $backupwkrec->prop('SmbHost');
2283 + my $smbshare = $backupwkrec->prop('SmbShare');
2284 + my $err;
2285 +
2286 + if ( $err = dmount($smbhost,$smbshare,$mntdir,$login,$password,$VFSType) )
2287 + {
2288 + esmith::cgi::genHeaderNonCacheable(
2289 + $q,
2290 + undef, $fm->localise('RESTORE_CANNOT_PROCEED')
2291 + );
2292 + esmith::cgi::genResult(
2293 + $q, $fm->localise('ERR_MOUNTING_SMBSHARE') . "\n" . $err
2294 + );
2295 + return;
2296 + }
2297 + elsif ( $VFSType ne 'usb' ) {$mounted = 1}
2298 +
2299 + # Test if backup subdirectory for our server
2300 +
2301 + my $mntbkdir = $mntdir . "/$id";
2302 + unless ( -d $mntbkdir)
2303 + {
2304 + if ($mounted) {
2305 + system("/bin/umount $mntdir") == 0
2306 + or die($fm->localise('ERR_WHILE_UNMOUNTING'),"\n");
2307 + }
2308 + esmith::cgi::genResult(
2309 + $q, $fm->localise('ERR_NO_HOST_DIR'.$id)
2310 + );
2311 + return;
2312 + }
2313 +
2314 + # finding list of available backups
2315 +
2316 + find { wanted => \&$backupsetlist, untaint => 1 }, $set ;
2317 +
2318 + my $key;
2319 + foreach $key (sort keys %backupsetfiles) {
2320 + push @restorefiles, $backupsetfiles{$key};
2321 + last if ( $backupsetfiles{$key} eq $restoreref );
2322 + }
2323 +
2324 + # backup is online, restoring now
2325 +
2326 + my $rec = $restore->get('restore');
2327 + $rec->set_prop('state','running');
2328 + $rec->set_prop('start', time);
2329 + $conf->get('bootstrap-console')->set_prop('Run', 'yes');
2330 +
2331 + unless (system("/sbin/e-smith/signal-event", "pre-restore") == 0)
2332 + {
2333 + esmith::cgi::genHeaderNonCacheable(
2334 + $fm->{cgi},
2335 + undef, $fm->localise('OPERATION_STATUS_REPORT'));
2336 + esmith::cgi::genResult(
2337 + $fm->{cgi}, $fm->localise('ERR_PRE_RESTORE'));
2338 + return;
2339 + }
2340 +
2341 + $| = 1;
2342 +
2343 + if (open(RD, "-|"))
2344 + {
2345 +
2346 + #-----------------------------------------------------
2347 + # restore system from uploaded workstation backup file
2348 + #-----------------------------------------------------
2349 +
2350 + esmith::cgi::genHeaderNonCacheable ($q, undef,
2351 + $fm->localise('RESTORE_IN_PROGRESS'));
2352 +
2353 + print $q->p (
2354 + $q->b ($fm->localise('RESTORE_IN_PROGRESS_DESC')
2355 + )
2356 + );
2357 +
2358 + print $q->p($fm->localise('FILES_HAVE_BEEN_RESTORED'));
2359 +
2360 + print '<UL>';
2361 + my $complete = 0;
2362 + while (<RD>)
2363 + {
2364 + $complete++ if /etc\/smbpasswd$/;
2365 + $complete++ if /etc\/samba\/smbpassword$/;
2366 + print "<li>$_</li>\n";
2367 + }
2368 +
2369 + print '</UL>';
2370 + my $message;
2371 + if (!close RD)
2372 + {
2373 + $message = $fm->localise('RESTORE_FAILED_MSG');
2374 + }
2375 + else
2376 + {
2377 + #-----------------------------------------------------
2378 + # if restore completed, regenerate configuration files
2379 + #-----------------------------------------------------
2380 + if ($complete)
2381 + {
2382 +
2383 + $message = $fm->localise('RESTORE_COMPLETE');
2384 + system("/usr/sbin/groupmod", "-g", "$www_gid", "www") == 0
2385 + or warn ($fm->localise('ERR_RESTORING_GID')."\n");
2386 + system("/usr/sbin/usermod", "-g", "$www_gid", "www") == 0
2387 + or warn ($fm->localise('ERR_RESTORING_INITIAL_GRP')."\n");
2388 + system("/sbin/e-smith/signal-event", "post-upgrade") == 0
2389 + or die ($fm->localise('ERR_UPDATING_SYSCONF')."\n");
2390 + }
2391 + else
2392 + {
2393 + $message = $fm->localise('RESTORE_FAILED');
2394 + }
2395 + }
2396 +
2397 + $rec->set_prop('state', 'complete');
2398 + $rec->set_prop('finish', time);
2399 +
2400 + &esmith::lockfile::UnlockFile($file_handle);
2401 +
2402 + print $q->p ($q->b ($message));
2403 +
2404 + print $q->startform(
2405 + -method => 'POST',
2406 + -action => $q->url (-absolute => 1)
2407 + );
2408 + print $q->p($q->b ($fm->localise('YOU_MUST_REBOOT'))),"\n";
2409 + print $q->start_table ({width => "100%", -class => "sme-noborders"}),"\n";
2410 + print esmith::cgi::genButtonRow(
2411 + $q,
2412 + $q->submit (-name => 'action', -value =>
2413 + $fm->localise('REBOOT'))
2414 + );
2415 + # Put in a hidden widget to store the reboot value.
2416 + print $q->hidden(
2417 + -name => 'function',
2418 + -value => 'reboot'
2419 + ),"\n";
2420 + print $q->hidden (
2421 + -name => 'state',
2422 + -override => 1,
2423 + -default => 'perform'
2424 + ),"\n";
2425 + print $q->end_table,"\n";
2426 + print $q->endform;
2427 +
2428 + esmith::cgi::genFooter ($q);
2429 + }
2430 + else
2431 + {
2432 + select(STDOUT);
2433 + $| = 1;
2434 +
2435 + my $file;
2436 + foreach $file (@restorefiles) {
2437 + if ($file =~ /^(.*)$/) {
2438 + $file = $1;
2439 + }
2440 + else {
2441 + if ($mounted) {
2442 + system("/bin/umount $mntdir") == 0
2443 + or die($fm->localise('ERR_WHILE_UNMOUNTING'),"\n");
2444 + }
2445 + die('Unsecure data : ' . $file);
2446 + }
2447 + system ("/usr/bin/dar -x $file --verbose --noconf --no-warn=all");
2448 + }
2449 +
2450 + if ($mounted) {
2451 + system("/bin/umount $mntdir") == 0
2452 + or die($fm->localise('ERR_WHILE_UNMOUNTING'),"\n");
2453 + }
2454 +
2455 + exit(0);
2456 + }
2457 + return;
2458 +}
2459 +
2460 +sub workstnSelRestore()
2461 +{
2462 + my $rec = $conf->get('backupwk');
2463 +
2464 + esmith::cgi::genHeaderNonCacheable ($q, undef,
2465 + $fm->localise('WORKSTN_SELECTIVE_RESTORE'));
2466 +
2467 + unless ($rec)
2468 + {
2469 + esmith::cgi::genResult(
2470 + $q, $fm->localise('CONFIGURATION_TO_BE_DONE'));
2471 + return;
2472 + }
2473 +
2474 + my %backupfiles = ();
2475 + my $mntdir = $rec->prop('MountDir') || '/mnt/smb';
2476 + my $mntbkdir;
2477 + my $mounted;
2478 + my $key;
2479 + my $id = $rec->prop('Id') || $conf->get('SystemName')->value . '.' . $conf->get('DomainName')->value;
2480 + my %blabels = ();
2481 + my @blabels;
2482 + my $backups = 0;
2483 + my $filterexp;
2484 + my $VFSType = $rec->prop('VFSType') || 'smbfs';
2485 + my $smbhost = $rec->prop('SmbHost');
2486 + my $smbshare = $rec->prop('SmbShare');
2487 + my $err;
2488 +
2489 + my $setbackuplist = sub {
2490 + if ( $_ =~ /\.dar/ ) {
2491 + my $dir = $File::Find::dir;
2492 + my $backupref;
2493 + $dir =~ s/$mntbkdir\///;
2494 + $_ =~ s/\..*\.dar//;
2495 + $backupref = $_;
2496 + $_ =~ s/.*-//;
2497 + @{$backupfiles{$_}}[0] = $dir;
2498 + @{$backupfiles{$_}}[1] = $backupref;
2499 + }
2500 + };
2501 +
2502 + # Mounting backups smb shared folder
2503 +
2504 + unless (-d $mntdir)
2505 + {
2506 + mkdir -p $mntdir;
2507 + }
2508 +
2509 + my $login = $rec->prop('Login') || 'backup';
2510 + my $password = $rec->prop('Password') || 'backup';
2511 +
2512 + if ( $err = dmount($smbhost,$smbshare,$mntdir,$login,$password,$VFSType) )
2513 + {
2514 + esmith::cgi::genResult(
2515 + $q, $fm->localise('ERR_MOUNTING_SMBSHARE') . "\n" . $err
2516 + );
2517 + return;
2518 + }
2519 + elsif ( $VFSType ne 'usb' ) {$mounted = 1}
2520 +
2521 + # Test if backup subdirectory for our server
2522 +
2523 + $mntbkdir = $mntdir . '/' . $id;
2524 + unless ( -d $mntbkdir)
2525 + {
2526 + if ($mounted) {
2527 + system("/bin/umount $mntdir") == 0
2528 + or die($fm->localise('ERR_WHILE_UNMOUNTING'),"\n");
2529 + }
2530 + esmith::cgi::genResult(
2531 + $q, $fm->localise('ERR_NO_HOST_DIR'.$id)
2532 + );
2533 + return;
2534 + }
2535 +
2536 + my $catalog = "$mntbkdir/dar-catalog";
2537 + unless ( -e $catalog)
2538 + {
2539 + system("/usr/bin/dar_manager -C $catalog") == 0
2540 + or die($fm->localise('ERR_DAR_CATALOG'),"\n");
2541 + }
2542 +
2543 + # find available backups for the server
2544 +
2545 + find { wanted => \&$setbackuplist, untaint => 1 }, $mntbkdir ;
2546 +
2547 + # find backups in current catalog
2548 +
2549 + my $i = 0;
2550 + my @bknum;
2551 + my @setd;
2552 + my @bkname;
2553 + open(DAR_LIST, "/usr/bin/dar_manager -B $catalog -l |");
2554 + while (<DAR_LIST>) {
2555 + next unless ($_ =~ /set/);
2556 + chomp;
2557 + ($bknum[$i], $setd[$i], $bkname[$i]) = split(' ', $_, 3);
2558 + $i++;
2559 + }
2560 + close (DAR_LIST);
2561 +
2562 + # delete from catalog old removed backups
2563 +
2564 + my $j = $i;
2565 + while ($j) {
2566 + unless (-e "$setd[$j-1]/$bkname[$j-1]\.1\.dar") {
2567 + my $del = $bknum[$j-1];
2568 + if ($del =~ /^(.*)$/) {
2569 + $del = $1;
2570 + }
2571 + system("/usr/bin/dar_manager -B $catalog -D $del 1>&2") == 0
2572 + or die($fm->localise('ERR_DAR_CATALOG'),"\n");
2573 + }
2574 + $j--;
2575 + }
2576 +
2577 + # add to catalog new backups
2578 +
2579 + foreach $key (sort keys %backupfiles) {
2580 + my $exists = 0;
2581 + my $rf;
2582 + foreach $rf (@bkname) {
2583 + $exists = 1 if ($rf eq $backupfiles{$key}[1]);
2584 + last if $exists;
2585 + }
2586 + do {
2587 + my $add = "$mntbkdir/$backupfiles{$key}[0]/$backupfiles{$key}[1]";
2588 + if ($add =~ /^(.*)$/) {
2589 + $add = $1;
2590 + }
2591 + system("/usr/bin/dar_manager -B $catalog -A $add") == 0
2592 + or die($fm->localise('ERR_DAR_CATALOG'),"\n");
2593 + } unless $exists;
2594 + }
2595 +
2596 + # update backups list from current catalog
2597 +
2598 + open(DAR_LIST, "/usr/bin/dar_manager -B $catalog -l |") ;
2599 +
2600 + $i = 0;
2601 + while (<DAR_LIST>) {
2602 + next unless m/set/;
2603 + chomp;
2604 + ($bknum[$i], $setd[$i], $bkname[$i]) = split(' ', $_, 3);
2605 + $i++;
2606 + }
2607 + close (DAR_LIST);
2608 +
2609 + # set drop down list of backups
2610 +
2611 + push @blabels, "0";
2612 + $blabels{"0"} = $fm->localise('ALL_BACKUPS');
2613 + $j = 0;
2614 + while ($j < $i) {
2615 + push @blabels, $bknum[$j];
2616 + $blabels{$bknum[$j]} = $bkname[$j];
2617 + $j++
2618 + }
2619 +
2620 + print $q->p ($fm->localise('WORKSTN_SEL_REST_DESC') . " $smbhost/$smbshare/$id");
2621 +
2622 + print $q->h2 ($fm->localise('BACKUP_CHOICE'));
2623 +
2624 + print $q->start_multipart_form(
2625 + -method => 'POST',
2626 + -action => $q->url (-absolute => 1)
2627 + );
2628 +
2629 +
2630 + print $q->table ({border => 0, cellspacing => 0, cellpadding => 4},
2631 +
2632 + esmith::cgi::genWidgetRow(
2633 + $q,
2634 + $q->b($fm->localise('SELECT_BACKUP_FILE')),
2635 + $q->popup_menu (
2636 + -name => 'backupset',
2637 + -values => [ @blabels ],
2638 + -labels => \%blabels)
2639 + ),
2640 +
2641 + esmith::cgi::genNameValueRow(
2642 + $q,
2643 + $fm->localise('FILTER_EXPRESSION'),
2644 + 'filterexp',
2645 + $filterexp
2646 + )
2647 + );
2648 +
2649 +
2650 + print $q->table ({width => "100%", -class => "sme-noborders"},
2651 + esmith::cgi::genButtonRow(
2652 + $q,
2653 + $q->submit(
2654 + -name => 'action',
2655 + -value => $fm->localise('PERFORM')
2656 + )
2657 + )
2658 + ),"\n";
2659 +
2660 + print $q->hidden(
2661 + -name => 'state',
2662 + -override => 1,
2663 + -default => 'workstn-sel-restore'
2664 + );
2665 +
2666 + print $q->endform;
2667 +
2668 +
2669 + esmith::cgi::genFooter ($q);
2670 +
2671 + if ($mounted) {
2672 + system("/bin/umount $mntdir") == 0
2673 + or die($fm->localise('ERR_WHILE_UNMOUNTING'),"\n");
2674 + }
2675 +}
2676 +
2677 +sub performWorkstnSelRestore
2678 +{
2679 + my ($q) = @_;
2680 +
2681 + my $rgfilter;
2682 + my $filterexp = $q->param ('filterexp');
2683 + if ($filterexp =~ /^(.*)$/) {
2684 + $filterexp = $1;
2685 + $rgfilter = qr/$filterexp/;
2686 + } else {
2687 + $filterexp = "";
2688 + }
2689 + my $seldatebf;
2690 +
2691 + esmith::cgi::genHeaderNonCacheable ($q,
2692 + undef, $fm->localise('WORKSTN_SELECTIVE_RESTORE'));
2693 +
2694 + my $backupwkrec = $conf->get('backupwk');
2695 + my $smbhost = $backupwkrec->prop('SmbHost');
2696 + my $smbshare = $backupwkrec->prop('SmbShare');
2697 + my $login = $backupwkrec->prop('Login');
2698 + my $password = $backupwkrec->prop('Password');
2699 + my $mntdir = $backupwkrec->prop('MountDir') || '/mnt/smb';
2700 + my $mntbkdir;
2701 + my $mounted;
2702 + my $key;
2703 + my $id = $backupwkrec->prop('Id') || $conf->get('SystemName')->value . "." . $conf->get('DomainName')->value;
2704 + my @flabels;
2705 + my %flabels = ();
2706 + my $VFSType = $backupwkrec->prop('VFSType') || 'smbfs';
2707 + my $err;
2708 +
2709 + my $backupkey = $q->param ('backupset');
2710 + if ($backupkey =~ /^(.*)$/) {
2711 + $backupkey = $1;
2712 + }
2713 + else {
2714 + die('Unsecure data : ' . $backupkey);
2715 + }
2716 +
2717 + # Mounting backup shared folder
2718 +
2719 + if ( $err = dmount($smbhost,$smbshare,$mntdir,$login,$password,$VFSType) )
2720 + {
2721 + esmith::cgi::genResult(
2722 + $q, $fm->localise('ERR_MOUNTING_SMBSHARE') . "\n" . $err
2723 + );
2724 + return;
2725 + }
2726 + elsif ( $VFSType ne 'usb' ) {$mounted = 1}
2727 +
2728 + # Test if backup subdirectory for our server
2729 +
2730 + $mntbkdir = $mntdir . "/$id";
2731 + unless ( -d $mntbkdir)
2732 + {
2733 + if ($mounted) {
2734 + system("/bin/umount $mntdir") == 0
2735 + or die($fm->localise('ERR_WHILE_UNMOUNTING'),"\n");
2736 + }
2737 + esmith::cgi::genResult(
2738 + $q, $fm->localise('ERR_NO_HOST_DIR'.$id)
2739 + );
2740 + return;
2741 + }
2742 +
2743 + # Read wanted file list from selected backup
2744 +
2745 + if (open(RD, "-|"))
2746 + {
2747 + my $regex = qr/\[.*\] */;
2748 + while (<RD>)
2749 + {
2750 + $_ =~ s/$regex//;
2751 + if ($filterexp) {next unless m/$rgfilter/};
2752 + push @flabels, $_;
2753 + }
2754 +
2755 + my $status = close RD ?
2756 + $fm->localise('READ_COMPLETE')
2757 + : ($fm->localise('ERROR_READING_FILE').' : '.$backupkey);
2758 + print $q->p ($status);
2759 +
2760 + }
2761 + else
2762 + {
2763 + select(STDOUT);
2764 + $| = 1;
2765 +
2766 + system ("/usr/bin/dar_manager -B $mntbkdir/dar-catalog -u $backupkey") == 0
2767 + or die ($fm->localise('ERR_EXTRACT')." : ".$!);
2768 +
2769 + if ($mounted) {
2770 + system("/bin/umount $mntdir") == 0
2771 + or die($fm->localise('ERR_WHILE_UNMOUNTING'),"\n");
2772 + }
2773 + exit(0);
2774 + }
2775 +
2776 + print $q->start_multipart_form(
2777 + -method => 'POST',
2778 + -action => $q->url (-absolute => 1)
2779 + );
2780 +
2781 + print $q->table ({border => 0, cellspacing => 0, cellpadding => 4},
2782 +
2783 + esmith::cgi::genWidgetRow(
2784 + $q,
2785 + $q->b($fm->localise('SELECT_FILES_TO_RESTORE')),
2786 + $q->scrolling_list (
2787 + -name => 'restorefiles',
2788 + -values => [ @flabels ],
2789 + -size => 15,
2790 + -multiple => 'true')
2791 + ),
2792 +
2793 + esmith::cgi::genNameValueRow(
2794 + $q,
2795 + $fm->localise('SELECT_DATE_BEFORE'),
2796 + 'seldatebefore',
2797 + $seldatebf
2798 + )
2799 + );
2800 +
2801 + print $q->table ({width => "100%", -class => "sme-noborders"},
2802 + esmith::cgi::genButtonRow(
2803 + $q,
2804 + $q->submit(
2805 + -name => 'action',
2806 + -value => $fm->localise('PERFORM')
2807 + )
2808 + )
2809 + ),"\n";
2810 +
2811 + print $q->hidden(
2812 + -name => 'state',
2813 + -override => 1,
2814 + -default => 'workstn-sel-restore2'
2815 + );
2816 +
2817 + print $q->hidden(
2818 + -name => 'when',
2819 + -override => 1,
2820 + -value => $seldatebf
2821 + );
2822 +
2823 + print $q->endform;
2824 +
2825 + esmith::cgi::genFooter ($q);
2826 +
2827 +}
2828 +
2829 +sub performWorkstnSelRestore2
2830 +{
2831 + my ($q) = @_;
2832 +
2833 + esmith::cgi::genHeaderNonCacheable ($q, undef,
2834 + $fm->localise('RESTORE_IN_PROGRESS'));
2835 +
2836 + my @restorelist;
2837 + my $when = $q->param ('seldatebefore');
2838 + if ($when =~ /^(.*)$/) {
2839 + $when = $1;
2840 + }
2841 + else {
2842 + die('Unsecure data : ' . $when);
2843 + }
2844 + 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])-)?/;
2845 + my $thms = qr/([01]?[0-9]|2[0-3]):([0-5][0-9])(:[0-5][0-9])?/;
2846 +
2847 + unless (($when =~ m/^$tymd$thms$/) || ($when eq "")) {
2848 + esmith::cgi::genResult(
2849 + $q, "$when : " . $fm->localise('ERR_INVALID_SELDATE')
2850 + );
2851 + return;
2852 + }
2853 +
2854 + my $f;
2855 + foreach $f ($q->param ('restorefiles')) {
2856 + if ($f =~ /^(.*)$/) {
2857 + push @restorelist, "\"".$1."\"";
2858 + }
2859 + }
2860 +
2861 + # mounting backup shared folder
2862 +
2863 + my $backupwkrec = $conf->get('backupwk');
2864 + my $login = $backupwkrec->prop('Login');
2865 + my $password = $backupwkrec->prop('Password');
2866 + my $id = $backupwkrec->prop('Id') || $conf->get('SystemName')->value . "." . $conf->get('DomainName')->value;
2867 + my $mntdir = $backupwkrec->prop('MountDir') || '/mnt/smb';
2868 + my $mounted;
2869 + my $VFSType = $backupwkrec->prop('VFSType') || 'smbfs';
2870 + my $smbhost = $backupwkrec->prop('SmbHost');
2871 + my $smbshare = $backupwkrec->prop('SmbShare');
2872 + my $err;
2873 +
2874 + if ( $err = dmount($smbhost,$smbshare,$mntdir,$login,$password,$VFSType) )
2875 + {
2876 + esmith::cgi::genResult(
2877 + $q, $fm->localise('ERR_MOUNTING_SMBSHARE') . "\n" . $err
2878 + );
2879 + return;
2880 + }
2881 + elsif ( $VFSType ne 'usb' ) {$mounted = 1}
2882 +
2883 + # Test if backup subdirectory for our server
2884 +
2885 + my $mntbkdir = $mntdir . "/$id";
2886 + unless ( -d $mntbkdir)
2887 + {
2888 + if ($mounted) {
2889 + system("/bin/umount $mntdir") == 0
2890 + or die($fm->localise('ERR_WHILE_UNMOUNTING'),"\n");
2891 + }
2892 + esmith::cgi::genResult(
2893 + $q, $fm->localise('ERR_NO_HOST_DIR'.$id)
2894 + );
2895 + return;
2896 + }
2897 +
2898 + # backup is online, restoring now
2899 +
2900 + $| = 1;
2901 + my $restorerr;
2902 +
2903 + if (open(RD, "-|"))
2904 + {
2905 +
2906 + #-----------------------------------------------------
2907 + # restore system from uploaded workstation backup file
2908 + #-----------------------------------------------------
2909 +
2910 + print $q->p($fm->localise('FILES_HAVE_BEEN_RESTORED'));
2911 +
2912 + print '<UL>';
2913 + while (<RD>)
2914 + {
2915 + print "<li>$_</li>\n";
2916 + }
2917 +
2918 + print '</UL>';
2919 + my $message;
2920 + if (!close RD)
2921 + {
2922 + $message = $fm->localise('RESTORE_FAILED_MSG');
2923 + }
2924 + else
2925 + {
2926 + if ($restorerr)
2927 + {
2928 + $message = $fm->localise('RESTORE_FAILED');
2929 + }
2930 + else
2931 + {
2932 + $message = $fm->localise('RESTORE_COMPLETE');
2933 + }
2934 + }
2935 +
2936 + print $q->p ($q->b ($message));
2937 +
2938 + esmith::cgi::genFooter ($q);
2939 + }
2940 + else
2941 + {
2942 + select(STDOUT);
2943 + $| = 1;
2944 +
2945 + if ($when)
2946 + {
2947 + $restorerr = system ("/usr/bin/dar_manager -B $mntbkdir/dar-catalog -w $when -e '-N -R / -w' -r @restorelist");
2948 + }
2949 + else
2950 + {
2951 + $restorerr = system ("/usr/bin/dar_manager -B $mntbkdir/dar-catalog -e '-N -R / -w' -r @restorelist");
2952 + }
2953 +
2954 + if ($mounted) {
2955 + system("/bin/umount $mntdir") == 0
2956 + or die($fm->localise('ERR_WHILE_UNMOUNTING'),"\n");
2957 + }
2958 +
2959 + exit(0);
2960 + }
2961 +
2962 + return;
2963 +
2964 +}
2965 +
2966 +sub performReboot ()
2967 +{
2968 + esmith::cgi::genHeaderNonCacheable ($q, undef,
2969 + $fm->localise('SERVER_REBOOT'));
2970 +
2971 + print $q->p (
2972 + $q->b ($fm->localise('SERVER_WILL_REBOOT'))
2973 + );
2974 +
2975 + esmith::cgi::genFooter($fm);
2976 +
2977 + esmith::util::backgroundCommand(
2978 + 5,
2979 + "/sbin/e-smith/signal-event",
2980 + "reboot"
2981 + );
2982 +}
2983 +
2984 +sub CalculateSizes ()
2985 +{
2986 + #------------------------------------------------------------
2987 + # figure out the size of the tar file.
2988 + #------------------------------------------------------------
2989 +
2990 + my $tarsize = 0;
2991 +
2992 + # It takes way too much time to do a du on /home/e-smith. So we'll
2993 + # estimate the current size.
2994 + # We do this by checking the quota used by each user on the system.
2995 +
2996 + use Quota;
2997 + use esmith::AccountsDB;
2998 + my $accounts = esmith::AccountsDB->open;
2999 +
3000 + # Get a $dev value appropriate for use in Quota::query call.
3001 + my $dev = Quota::getqcarg("/home/e-smith/files");
3002 +
3003 + foreach my $user ($accounts->users())
3004 + {
3005 + my $name = $user->key;
3006 + my $uid = getpwnam($name);
3007 + unless ($uid)
3008 + {
3009 + warn ($fm->localise('NO_UID_FOR_NAME').$name."\n");
3010 + # We shouldn't ever get here. If we do, we can't get
3011 + # the quota value for this user, so we just skip to
3012 + # the next one.
3013 + next;
3014 + }
3015 +
3016 + # Get current quota settings.
3017 + my ($blocks) = Quota::query($dev, $uid, 0);
3018 + $tarsize += $blocks;
3019 + }
3020 +
3021 + # We add to this the size of root owned firectories, estimated using du.
3022 + # If this takes too long, then the admin only has his or
3023 + # herself to blame!
3024 +
3025 + # Remove /home/e-smith from backup list, and make paths absolute
3026 + my @list = map { "/$_" } grep { !/home\/e-smith/ } @directories;
3027 + open(DU, "-|")
3028 + or exec '/usr/bin/du', '-s', @list;
3029 +
3030 + while (<DU>)
3031 + {
3032 + my ($du) = split(/\s+/);
3033 + $tarsize += $du;
3034 + }
3035 + close DU;
3036 +
3037 + $tarsize = &showSize($tarsize);
3038 +
3039 + #------------------------------------------------------------
3040 + # figure out the size of the dump files
3041 + #------------------------------------------------------------
3042 +
3043 + my $dumpsize = 0;
3044 +
3045 + open(DF, "-|")
3046 + or exec '/bin/df', '-P', '-t', 'ext3';
3047 +
3048 + while (<DF>)
3049 + {
3050 + next unless (/^\//);
3051 +
3052 + (undef, undef, my $s, undef) = split(/\s+/, $_);
3053 +
3054 + $dumpsize += $s;
3055 + }
3056 +
3057 + # increase size by 10% to cope with dump overhead.
3058 +
3059 + $dumpsize *= 1.1;
3060 +
3061 + close DF;
3062 +
3063 + $dumpsize = &showSize($dumpsize);
3064 +
3065 + #------------------------------------------------------------
3066 + # how much free space is in /tmp
3067 + #------------------------------------------------------------
3068 +
3069 + my $tmpfree = 0;
3070 + my $halffree = 0;
3071 +
3072 + open(DF, "-|")
3073 + or exec '/bin/df', '-P', '-t', 'ext3', '/tmp';
3074 +
3075 + while (<DF>)
3076 + {
3077 + next unless (/^\//);
3078 +
3079 + (undef, undef, undef, my $s) = split(/\s+/, $_);
3080 +
3081 + $tmpfree += $s;
3082 + }
3083 +
3084 + close DF;
3085 +
3086 + $halffree = $tmpfree / 2;
3087 +
3088 + $tmpfree = &showSize($tmpfree);
3089 + $halffree = &showSize($halffree);
3090 +
3091 + return ($tarsize, $dumpsize, $tmpfree, $halffree);
3092 +}
3093 +
3094 +sub showSize
3095 +{
3096 + # convert size to Mb or Gb or Tb :) Remember, df reports in kb.
3097 +
3098 + my $size = shift;
3099 +
3100 + my $Mb = 1024;
3101 + my $Gb = $Mb * $Mb;
3102 + my $Tb = $Mb * $Mb * $Mb;
3103 +
3104 + if ($size >= $Tb)
3105 + {
3106 + $size /= $Tb;
3107 + $size = int($size) . "Tb";
3108 + }
3109 + elsif ($size >= $Gb)
3110 + {
3111 + $size /= $Gb;
3112 + $size = int($size) . "Gb";
3113 + }
3114 + elsif ($size >= $Mb)
3115 + {
3116 + $size /= $Mb;
3117 + $size = int($size) . "Mb";
3118 + }
3119 + else
3120 + {
3121 + $size .= "kb";
3122 + }
3123 +
3124 + return $size;
3125 +}
3126 +
3127 +sub dmount()
3128 +{
3129 + # mount dar unit according to dar-workstation configuration
3130 + # return nothing if mount successfull
3131 +
3132 + my ($host,$share,$mountdir,$login,$password,$VFSType) = @_;
3133 +
3134 + if ($VFSType eq 'cifs'){
3135 + return ( qx(/bin/mount -t cifs $host:$share $mountdir -o user=$login,pass=$password) );
3136 + }
3137 + elsif ($VFSType eq 'smbfs'){
3138 + return ( qx(/bin/mount -t smbfs //$host/$share $mountdir -o username=$login,password=$password,dmask=777,fmask=777,ip=$host 2>&1) );
3139 + }
3140 + elsif ($VFSType eq 'nfs'){
3141 + return ( qx(/bin/mount -t nfs -o nolock $host:/$share $mountdir 2>&1) );
3142 + }
3143 + elsif ($VFSType eq 'usb'){
3144 + $_[2] = "/" . $share;
3145 + return
3146 + }
3147 + else {return ("Error while mounting $host/$share : $VFSType not supported.\n")}
3148 +
3149 +}
3150
3151 __DATA__
3152 <form>
3153 diff -Nur -x '*.orig' -x '*.rej' e-smith-backup-1.15.0/root/sbin/e-smith/do_backupwk mezzanine_patched_e-smith-backup-1.15.0/root/sbin/e-smith/do_backupwk
3154 --- e-smith-backup-1.15.0/root/sbin/e-smith/do_backupwk 1969-12-31 19:00:00.000000000 -0500
3155 +++ mezzanine_patched_e-smith-backup-1.15.0/root/sbin/e-smith/do_backupwk 2007-09-05 15:52:45.000000000 -0400
3156 @@ -0,0 +1,74 @@
3157 +#! /usr/bin/perl -w
3158 +#----------------------------------------------------------------------
3159 +# copyright (C) 2006 SME Server
3160 +#
3161 +# This program is free software; you can redistribute it and/or modify
3162 +# it under the terms of the GNU General Public License as published by
3163 +# the Free Software Foundation; either version 2 of the License, or
3164 +# (at your option) any later version.
3165 +#
3166 +# This program is distributed in the hope that it will be useful,
3167 +# but WITHOUT ANY WARRANTY; without even the implied warranty of
3168 +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
3169 +# GNU General Public License for more details.
3170 +#
3171 +# You should have received a copy of the GNU General Public License
3172 +# along with this program; if not, write to the Free Software
3173 +# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
3174 +#
3175 +#----------------------------------------------------------------------
3176 +
3177 +use strict;
3178 +use esmith::ConfigDB;
3179 +use esmith::BackupHistoryDB;
3180 +
3181 +$ENV{PATH} = "/sbin/e-smith:/sbin:/bin:/usr/bin";
3182 +
3183 +my $conf = esmith::ConfigDB->open || die("Could not open config db\n");
3184 +my $backup = $conf->get('backupwk');
3185 +my $status = $backup->prop('status') || 'disabled';
3186 +my $program = $backup->prop('Program') || 'dar';
3187 +
3188 +unless ($status eq 'enabled')
3189 +{
3190 + print "Backup is disabled\n";
3191 + exit 0;
3192 +}
3193 +
3194 +my $backups = esmith::BackupHistoryDB->open
3195 + || die("Could not open backup history db\n");
3196 +my $now = time();
3197 +my $backup_rec = $backups->new_record($now, { type => 'backup_record' });
3198 +$backup_rec->set_prop('StartEpochTime', "$now");
3199 +$backup_rec->set_prop('BackupType', "workstation");
3200 +
3201 +if ($status = system(qw(signal-event pre-backup)))
3202 +{
3203 + exit bad_exit($backup_rec, "pre-backup", $status);
3204 +}
3205 +
3206 +if ($status = system("/etc/e-smith/events/actions/workstation-backup-$program DailyBackup"))
3207 +{
3208 + exit bad_exit($backup_rec, "backup", $status);
3209 +}
3210 +
3211 +if ($status = system(qw(signal-event post-backup)))
3212 +{
3213 + exit bad_exit($backup_rec, "post-backup", $status);
3214 +}
3215 +
3216 +$now = time();
3217 +$backup_rec->set_prop('EndEpochTime', "$now");
3218 +$backup_rec->set_prop('Result', "$status");
3219 +exit 0;
3220 +
3221 +sub bad_exit
3222 +{
3223 + my ($backup_rec, $phase, $status) = @_;
3224 + my $now = time();
3225 +
3226 + warn("Backup terminated: $phase failed - status: $status\n");
3227 + $backup_rec->set_prop('EndEpochTime', "$now");
3228 + $backup_rec->set_prop('Result', "$phase:$status");
3229 + return $status / 256;
3230 +}

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