initial commit of file from CVS for e-smith-backup on Thu 26 Oct 11:24:24 BST 2023

This commit is contained in:
Brian Read 2023-10-26 11:24:24 +01:00
parent bb6b15a5a9
commit fe41ccadec
81 changed files with 9900 additions and 2 deletions

4
.gitignore vendored Normal file
View File

@ -0,0 +1,4 @@
*.rpm
*.log
*spec-20*
*.tar.xz

21
Makefile Normal file
View File

@ -0,0 +1,21 @@
# Makefile for source rpm: e-smith-backup
# $Id: Makefile,v 1.1 2016/02/04 23:12:12 vip-ire Exp $
NAME := e-smith-backup
SPECFILE = $(firstword $(wildcard *.spec))
define find-makefile-common
for d in common ../common ../../common ; do if [ -f $$d/Makefile.common ] ; then if [ -f $$d/CVS/Root -a -w $$/Makefile.common ] ; then cd $$d ; cvs -Q update ; fi ; echo "$$d/Makefile.common" ; break ; fi ; done
endef
MAKEFILE_COMMON := $(shell $(find-makefile-common))
ifeq ($(MAKEFILE_COMMON),)
# attept a checkout
define checkout-makefile-common
test -f CVS/Root && { cvs -Q -d $$(cat CVS/Root) checkout common && echo "common/Makefile.common" ; } || { echo "ERROR: I can't figure out how to checkout the 'common' module." ; exit -1 ; } >&2
endef
MAKEFILE_COMMON := $(shell $(checkout-makefile-common))
endif
include $(MAKEFILE_COMMON)

View File

@ -1,3 +1,17 @@
# e-smith-backup
# <img src="https://www.koozali.org/images/koozali/Logo/Png/Koozali_logo_2016.png" width="25%" vertical="auto" style="vertical-align:bottom"> e-smith-backup
SMEServer Koozali developed git repo for e-smith-backup smeserver
## Wiki
<br />https://wiki.koozali.org/
## Bugzilla
Show list of outstanding bugs: [here](https://bugs.koozali.org/buglist.cgi?component=e-smith-backup&product=SME%20Server%2010.X&query_format=advanced&limit=0&bug_status=UNCONFIRMED&bug_status=NEW&bug_status=ASSIGNED&bug_status=REOPENED&bug_status=CONFIRMED)
## Description
<br />*This description has been generated by an LLM AI system and cannot be relied on to be fully correct.*
*Once it has been checked, then this comment will be deleted*
<br />
E-smith-backup is a software package that makes it easy to create a backup of your data. It can be used to create a regular backup of your documents, applications, emails, and other important files. It also allows you to customize the backup in order to keep only the most important files. The backup can be stored on an external hard drive, cloud storage, or a network storage. The software also provides a comprehensive suite of tools and features to help you manage and monitor your backups. This includes the ability to generate reports, set up email notifications, and even to perform file and folder comparisons. With e-smith-backup, you can rest assured that your most important data is safe and secure.

131
additional/Artistic Normal file
View File

@ -0,0 +1,131 @@
The "Artistic License"
Preamble
The intent of this document is to state the conditions under which a
Package may be copied, such that the Copyright Holder maintains some
semblance of artistic control over the development of the package,
while giving the users of the package the right to use and distribute
the Package in a more-or-less customary fashion, plus the right to make
reasonable modifications.
Definitions:
"Package" refers to the collection of files distributed by the
Copyright Holder, and derivatives of that collection of files
created through textual modification.
"Standard Version" refers to such a Package if it has not been
modified, or has been modified in accordance with the wishes
of the Copyright Holder as specified below.
"Copyright Holder" is whoever is named in the copyright or
copyrights for the package.
"You" is you, if you're thinking about copying or distributing
this Package.
"Reasonable copying fee" is whatever you can justify on the
basis of media cost, duplication charges, time of people involved,
and so on. (You will not be required to justify it to the
Copyright Holder, but only to the computing community at large
as a market that must bear the fee.)
"Freely Available" means that no fee is charged for the item
itself, though there may be fees involved in handling the item.
It also means that recipients of the item may redistribute it
under the same conditions they received it.
1. You may make and give away verbatim copies of the source form of the
Standard Version of this Package without restriction, provided that you
duplicate all of the original copyright notices and associated disclaimers.
2. You may apply bug fixes, portability fixes and other modifications
derived from the Public Domain or from the Copyright Holder. A Package
modified in such a way shall still be considered the Standard Version.
3. You may otherwise modify your copy of this Package in any way, provided
that you insert a prominent notice in each changed file stating how and
when you changed that file, and provided that you do at least ONE of the
following:
a) place your modifications in the Public Domain or otherwise make them
Freely Available, such as by posting said modifications to Usenet or
an equivalent medium, or placing the modifications on a major archive
site such as uunet.uu.net, or by allowing the Copyright Holder to include
your modifications in the Standard Version of the Package.
b) use the modified Package only within your corporation or organization.
c) rename any non-standard executables so the names do not conflict
with standard executables, which must also be provided, and provide
a separate manual page for each non-standard executable that clearly
documents how it differs from the Standard Version.
d) make other distribution arrangements with the Copyright Holder.
4. You may distribute the programs of this Package in object code or
executable form, provided that you do at least ONE of the following:
a) distribute a Standard Version of the executables and library files,
together with instructions (in the manual page or equivalent) on where
to get the Standard Version.
b) accompany the distribution with the machine-readable source of
the Package with your modifications.
c) give non-standard executables non-standard names, and clearly
document the differences in manual pages (or equivalent), together
with instructions on where to get the Standard Version.
d) make other distribution arrangements with the Copyright Holder.
5. You may charge a reasonable copying fee for any distribution of this
Package. You may charge any fee you choose for support of this
Package. You may not charge a fee for this Package itself. However,
you may distribute this Package in aggregate with other (possibly
commercial) programs as part of a larger (possibly commercial) software
distribution provided that you do not advertise this Package as a
product of your own. You may embed this Package's interpreter within
an executable of yours (by linking); this shall be construed as a mere
form of aggregation, provided that the complete Standard Version of the
interpreter is so embedded.
6. The scripts and library files supplied as input to or produced as
output from the programs of this Package do not automatically fall
under the copyright of this Package, but belong to whoever generated
them, and may be sold commercially, and may be aggregated with this
Package. If such scripts or library files are aggregated with this
Package via the so-called "undump" or "unexec" methods of producing a
binary executable image, then distribution of such an image shall
neither be construed as a distribution of this Package nor shall it
fall under the restrictions of Paragraphs 3 and 4, provided that you do
not represent such an executable image as a Standard Version of this
Package.
7. C subroutines (or comparably compiled subroutines in other
languages) supplied by you and linked into this Package in order to
emulate subroutines and variables of the language defined by this
Package shall not be considered part of this Package, but are the
equivalent of input as in Paragraph 6, provided these subroutines do
not change the language in any way that would cause it to fail the
regression tests for the language.
8. Aggregation of this Package with a commercial distribution is always
permitted provided that the use of this Package is embedded; that is,
when no overt attempt is made to make this Package's interfaces visible
to the end user of the commercial distribution. Such use shall not be
construed as a distribution of this Package.
9. The name of the Copyright Holder may not be used to endorse or promote
products derived from this software without specific prior written permission.
10. THIS PACKAGE IS PROVIDED "AS IS" AND WITHOUT ANY EXPRESS OR
IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
The End

340
additional/Copying Normal file
View File

@ -0,0 +1,340 @@
GNU GENERAL PUBLIC LICENSE
Version 2, June 1991
Copyright (C) 1989, 1991 Free Software Foundation, Inc.
59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
Everyone is permitted to copy and distribute verbatim copies
of this license document, but changing it is not allowed.
Preamble
The licenses for most software are designed to take away your
freedom to share and change it. By contrast, the GNU General Public
License is intended to guarantee your freedom to share and change free
software--to make sure the software is free for all its users. This
General Public License applies to most of the Free Software
Foundation's software and to any other program whose authors commit to
using it. (Some other Free Software Foundation software is covered by
the GNU Library General Public License instead.) You can apply it to
your programs, too.
When we speak of free software, we are referring to freedom, not
price. Our General Public Licenses are designed to make sure that you
have the freedom to distribute copies of free software (and charge for
this service if you wish), that you receive source code or can get it
if you want it, that you can change the software or use pieces of it
in new free programs; and that you know you can do these things.
To protect your rights, we need to make restrictions that forbid
anyone to deny you these rights or to ask you to surrender the rights.
These restrictions translate to certain responsibilities for you if you
distribute copies of the software, or if you modify it.
For example, if you distribute copies of such a program, whether
gratis or for a fee, you must give the recipients all the rights that
you have. You must make sure that they, too, receive or can get the
source code. And you must show them these terms so they know their
rights.
We protect your rights with two steps: (1) copyright the software, and
(2) offer you this license which gives you legal permission to copy,
distribute and/or modify the software.
Also, for each author's protection and ours, we want to make certain
that everyone understands that there is no warranty for this free
software. If the software is modified by someone else and passed on, we
want its recipients to know that what they have is not the original, so
that any problems introduced by others will not reflect on the original
authors' reputations.
Finally, any free program is threatened constantly by software
patents. We wish to avoid the danger that redistributors of a free
program will individually obtain patent licenses, in effect making the
program proprietary. To prevent this, we have made it clear that any
patent must be licensed for everyone's free use or not licensed at all.
The precise terms and conditions for copying, distribution and
modification follow.
GNU GENERAL PUBLIC LICENSE
TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
0. This License applies to any program or other work which contains
a notice placed by the copyright holder saying it may be distributed
under the terms of this General Public License. The "Program", below,
refers to any such program or work, and a "work based on the Program"
means either the Program or any derivative work under copyright law:
that is to say, a work containing the Program or a portion of it,
either verbatim or with modifications and/or translated into another
language. (Hereinafter, translation is included without limitation in
the term "modification".) Each licensee is addressed as "you".
Activities other than copying, distribution and modification are not
covered by this License; they are outside its scope. The act of
running the Program is not restricted, and the output from the Program
is covered only if its contents constitute a work based on the
Program (independent of having been made by running the Program).
Whether that is true depends on what the Program does.
1. You may copy and distribute verbatim copies of the Program's
source code as you receive it, in any medium, provided that you
conspicuously and appropriately publish on each copy an appropriate
copyright notice and disclaimer of warranty; keep intact all the
notices that refer to this License and to the absence of any warranty;
and give any other recipients of the Program a copy of this License
along with the Program.
You may charge a fee for the physical act of transferring a copy, and
you may at your option offer warranty protection in exchange for a fee.
2. You may modify your copy or copies of the Program or any portion
of it, thus forming a work based on the Program, and copy and
distribute such modifications or work under the terms of Section 1
above, provided that you also meet all of these conditions:
a) You must cause the modified files to carry prominent notices
stating that you changed the files and the date of any change.
b) You must cause any work that you distribute or publish, that in
whole or in part contains or is derived from the Program or any
part thereof, to be licensed as a whole at no charge to all third
parties under the terms of this License.
c) If the modified program normally reads commands interactively
when run, you must cause it, when started running for such
interactive use in the most ordinary way, to print or display an
announcement including an appropriate copyright notice and a
notice that there is no warranty (or else, saying that you provide
a warranty) and that users may redistribute the program under
these conditions, and telling the user how to view a copy of this
License. (Exception: if the Program itself is interactive but
does not normally print such an announcement, your work based on
the Program is not required to print an announcement.)
These requirements apply to the modified work as a whole. If
identifiable sections of that work are not derived from the Program,
and can be reasonably considered independent and separate works in
themselves, then this License, and its terms, do not apply to those
sections when you distribute them as separate works. But when you
distribute the same sections as part of a whole which is a work based
on the Program, the distribution of the whole must be on the terms of
this License, whose permissions for other licensees extend to the
entire whole, and thus to each and every part regardless of who wrote it.
Thus, it is not the intent of this section to claim rights or contest
your rights to work written entirely by you; rather, the intent is to
exercise the right to control the distribution of derivative or
collective works based on the Program.
In addition, mere aggregation of another work not based on the Program
with the Program (or with a work based on the Program) on a volume of
a storage or distribution medium does not bring the other work under
the scope of this License.
3. You may copy and distribute the Program (or a work based on it,
under Section 2) in object code or executable form under the terms of
Sections 1 and 2 above provided that you also do one of the following:
a) Accompany it with the complete corresponding machine-readable
source code, which must be distributed under the terms of Sections
1 and 2 above on a medium customarily used for software interchange; or,
b) Accompany it with a written offer, valid for at least three
years, to give any third party, for a charge no more than your
cost of physically performing source distribution, a complete
machine-readable copy of the corresponding source code, to be
distributed under the terms of Sections 1 and 2 above on a medium
customarily used for software interchange; or,
c) Accompany it with the information you received as to the offer
to distribute corresponding source code. (This alternative is
allowed only for noncommercial distribution and only if you
received the program in object code or executable form with such
an offer, in accord with Subsection b above.)
The source code for a work means the preferred form of the work for
making modifications to it. For an executable work, complete source
code means all the source code for all modules it contains, plus any
associated interface definition files, plus the scripts used to
control compilation and installation of the executable. However, as a
special exception, the source code distributed need not include
anything that is normally distributed (in either source or binary
form) with the major components (compiler, kernel, and so on) of the
operating system on which the executable runs, unless that component
itself accompanies the executable.
If distribution of executable or object code is made by offering
access to copy from a designated place, then offering equivalent
access to copy the source code from the same place counts as
distribution of the source code, even though third parties are not
compelled to copy the source along with the object code.
4. You may not copy, modify, sublicense, or distribute the Program
except as expressly provided under this License. Any attempt
otherwise to copy, modify, sublicense or distribute the Program is
void, and will automatically terminate your rights under this License.
However, parties who have received copies, or rights, from you under
this License will not have their licenses terminated so long as such
parties remain in full compliance.
5. You are not required to accept this License, since you have not
signed it. However, nothing else grants you permission to modify or
distribute the Program or its derivative works. These actions are
prohibited by law if you do not accept this License. Therefore, by
modifying or distributing the Program (or any work based on the
Program), you indicate your acceptance of this License to do so, and
all its terms and conditions for copying, distributing or modifying
the Program or works based on it.
6. Each time you redistribute the Program (or any work based on the
Program), the recipient automatically receives a license from the
original licensor to copy, distribute or modify the Program subject to
these terms and conditions. You may not impose any further
restrictions on the recipients' exercise of the rights granted herein.
You are not responsible for enforcing compliance by third parties to
this License.
7. If, as a consequence of a court judgment or allegation of patent
infringement or for any other reason (not limited to patent issues),
conditions are imposed on you (whether by court order, agreement or
otherwise) that contradict the conditions of this License, they do not
excuse you from the conditions of this License. If you cannot
distribute so as to satisfy simultaneously your obligations under this
License and any other pertinent obligations, then as a consequence you
may not distribute the Program at all. For example, if a patent
license would not permit royalty-free redistribution of the Program by
all those who receive copies directly or indirectly through you, then
the only way you could satisfy both it and this License would be to
refrain entirely from distribution of the Program.
If any portion of this section is held invalid or unenforceable under
any particular circumstance, the balance of the section is intended to
apply and the section as a whole is intended to apply in other
circumstances.
It is not the purpose of this section to induce you to infringe any
patents or other property right claims or to contest validity of any
such claims; this section has the sole purpose of protecting the
integrity of the free software distribution system, which is
implemented by public license practices. Many people have made
generous contributions to the wide range of software distributed
through that system in reliance on consistent application of that
system; it is up to the author/donor to decide if he or she is willing
to distribute software through any other system and a licensee cannot
impose that choice.
This section is intended to make thoroughly clear what is believed to
be a consequence of the rest of this License.
8. If the distribution and/or use of the Program is restricted in
certain countries either by patents or by copyrighted interfaces, the
original copyright holder who places the Program under this License
may add an explicit geographical distribution limitation excluding
those countries, so that distribution is permitted only in or among
countries not thus excluded. In such case, this License incorporates
the limitation as if written in the body of this License.
9. The Free Software Foundation may publish revised and/or new versions
of the General Public License from time to time. Such new versions will
be similar in spirit to the present version, but may differ in detail to
address new problems or concerns.
Each version is given a distinguishing version number. If the Program
specifies a version number of this License which applies to it and "any
later version", you have the option of following the terms and conditions
either of that version or of any later version published by the Free
Software Foundation. If the Program does not specify a version number of
this License, you may choose any version ever published by the Free Software
Foundation.
10. If you wish to incorporate parts of the Program into other free
programs whose distribution conditions are different, write to the author
to ask for permission. For software which is copyrighted by the Free
Software Foundation, write to the Free Software Foundation; we sometimes
make exceptions for this. Our decision will be guided by the two goals
of preserving the free status of all derivatives of our free software and
of promoting the sharing and reuse of software generally.
NO WARRANTY
11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY
FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN
OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES
PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED
OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS
TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE
PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING,
REPAIR OR CORRECTION.
12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR
REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES,
INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING
OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED
TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY
YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER
PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE
POSSIBILITY OF SUCH DAMAGES.
END OF TERMS AND CONDITIONS
How to Apply These Terms to Your New Programs
If you develop a new program, and you want it to be of the greatest
possible use to the public, the best way to achieve this is to make it
free software which everyone can redistribute and change under these terms.
To do so, attach the following notices to the program. It is safest
to attach them to the start of each source file to most effectively
convey the exclusion of warranty; and each file should have at least
the "copyright" line and a pointer to where the full notice is found.
<one line to give the program's name and a brief idea of what it does.>
Copyright (C) 19yy <name of author>
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
Also add information on how to contact you by electronic and paper mail.
If the program is interactive, make it output a short notice like this
when it starts in an interactive mode:
Gnomovision version 69, Copyright (C) 19yy name of author
Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
This is free software, and you are welcome to redistribute it
under certain conditions; type `show c' for details.
The hypothetical commands `show w' and `show c' should show the appropriate
parts of the General Public License. Of course, the commands you use may
be called something other than `show w' and `show c'; they could even be
mouse-clicks or menu items--whatever suits your program.
You should also get your employer (if you work as a programmer) or your
school, if any, to sign a "copyright disclaimer" for the program, if
necessary. Here is a sample; alter the names:
Yoyodyne, Inc., hereby disclaims all copyright interest in the program
`Gnomovision' (which makes passes at compilers) written by James Hacker.
<signature of Ty Coon>, 1 April 1989
Ty Coon, President of Vice
This General Public License does not permit incorporating your program into
proprietary programs. If your program is a subroutine library, you may
consider it more useful to permit linking proprietary applications with the
library. If this is what you want to do, use the GNU Library General
Public License instead of this License.

33
additional/LICENSE Normal file
View File

@ -0,0 +1,33 @@
# Copyright 1999-2003 Mitel Networks Corporation
# This program is free software; you can redistribute it and/or
# modify it under the same terms as Perl itself.
Perl Kit, Version 5.0
Copyright 1989-2001, Larry Wall
All rights reserved.
This program is free software; you can redistribute it and/or modify
it under the terms of either:
a) the GNU General Public License as published by the Free
Software Foundation; either version 1, or (at your option) any
later version, or
b) the "Artistic License" which comes with this Kit.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See either
the GNU General Public License or the Artistic License for more details.
You should have received a copy of the Artistic License with this
Kit, in the file named "Artistic". If not, I'll be glad to provide one.
You should also have received a copy of the GNU General Public License
along with this program in the file named "Copying". If not, write to the
Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
02111-1307, USA or visit their web page on the internet at
http://www.gnu.org/copyleft/gpl.html.

1
contriborbase Normal file
View File

@ -0,0 +1 @@
sme10

86
createlinks Normal file
View File

@ -0,0 +1,86 @@
#!/usr/bin/perl -w
#----------------------------------------------------------------------
# Copyright 1999-2005 Mitel Networks Corporation
# This program is free software; you can redistribute it and/or
# modify it under the same terms as Perl itself.
#----------------------------------------------------------------------
# This script creates the symlinks needed by this RPM
# Specific support exists to create symlinks within e-smith web "panels"
# and for links from named "events" directories into the "actions" directory
use esmith::Build::CreateLinks qw(:all);
#--------------------------------------------------
# functions for manager panel
#--------------------------------------------------
my $panel = "manager";
panel_link("backup", $panel);
#--------------------------------------------------
# events for bootstrap-console-save
#--------------------------------------------------
$event = "bootstrap-console-save";
event_link("reset-restore-idle-flag", $event, "95");
templates2events("/etc/dar/CIFScredentials", $event);
#--------------------------------------------------
# events for conf-backup action
#--------------------------------------------------
$event = "conf-backup";
templates2events("/etc/crontab", $event);
templates2events("/etc/dar/CIFScredentials", $event);
templates2events("/etc/dar/DailyBackup.dcf", $event);
#--------------------------------------------------
# events for pre-backup action
#--------------------------------------------------
$event = "pre-backup";
templates2events("/etc/dar/DailyBackup.dcf", $event);
#--------------------------------------------------
# events for rewind-tape action
#--------------------------------------------------
foreach $event (qw(restore-tape pre-backup post-backup))
{
event_link("rewind-tape", $event, "50");
}
foreach $event (qw(post-backup))
{
event_link("eject-tape", $event, "90");
}
#--------------------------------------------------
foreach $event (qw(pre-restore))
{
event_link("save-system-files", $event, "10");
event_link("delete-index-htm", $event, "80");
}
#--------------------------------------------------
foreach $event (qw(post-upgrade))
{
event_link("merge-system-files", $event, "00");
}
foreach $event (qw(restore-tape))
{
event_link("restore-from-disk", $event, "40");
}
#--------------------------------------------------
$event="e-smith-backup-update";
event_link("merge-system-files", $event, "00");
templates2events("/etc/crontab", $event);
templates2events("/etc/dar/CIFScredentials", $event);
templates2events("/etc/dar/DailyBackup.dcf", $event);

1516
e-smith-backup.spec Normal file

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,2 @@
# All folder/file paths added here will NOT be saved
# For Example : /usr/share/wordpress/config

View File

@ -0,0 +1,2 @@
# All folder/file paths added here will be saved
# For Example : /usr/share/wordpress

0
root/etc/dar/.gitignore vendored Normal file
View File

View File

View File

@ -0,0 +1 @@
tape

View File

@ -0,0 +1 @@
flexbackup

View File

@ -0,0 +1 @@
2:00

View File

@ -0,0 +1 @@
14:00

View File

@ -0,0 +1 @@
disabled

View File

@ -0,0 +1 @@
service

View File

@ -0,0 +1 @@
22:00

View File

@ -0,0 +1 @@
6

View File

@ -0,0 +1 @@
gzip

View File

@ -0,0 +1 @@
1

View File

@ -0,0 +1 @@
backup

View File

@ -0,0 +1 @@
backup

View File

@ -0,0 +1 @@
dar

View File

@ -0,0 +1 @@
1

View File

@ -0,0 +1 @@
host

View File

@ -0,0 +1 @@
share

View File

@ -0,0 +1 @@
8

View File

@ -0,0 +1 @@
cifs

View File

@ -0,0 +1 @@
disabled

View File

@ -0,0 +1 @@
service

View File

@ -0,0 +1,2 @@
#! /bin/sh
exec rm -f /home/e-smith/files/ibays/Primary/html/index.htm

View File

@ -0,0 +1,22 @@
#!/usr/bin/perl -w
package esmith;
use strict;
use esmith::ConfigDB;
my $event = shift;
my $cause = shift;
exit 0 if not defined $cause or $cause ne "tape";
my $confdb = esmith::ConfigDB->open_ro;
my $backup = $confdb->get('backup') or die "No backup db entry found\n";
my $device = $backup->prop('Device') || '/dev/st0';
my $eject = $backup->prop('Eject') || 'no';
exit 0 unless $device =~ /[sh]t/;
if (lc($eject) eq 'yes') {
exec("/bin/mt", "-f", $device, "eject");
die("A problem occurred execing mt");
}

View File

@ -0,0 +1,31 @@
#!/usr/bin/perl -w
#----------------------------------------------------------------------
# copyright (C) 1999-2003 Mitel Networks Corporation
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
#
# Technical support for this program is available from Mitel Networks
# Please visit our web site www.mitel.com/sme/ for details.
#----------------------------------------------------------------------
use esmith::Backup;
my $backup = new esmith::Backup or die "Couldn't create Backup object\n";
unless ($backup->merge_system_files)
{
die "Error merging system files\n";
}
exit 0;

View File

@ -0,0 +1,41 @@
#!/usr/bin/perl -w
#----------------------------------------------------------------------
# copyright (C) 2001 e-smith, inc.
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
#
# Technical support for this program is available from e-smith, inc.
# Please visit our web site www.e-smith.com for details.
#----------------------------------------------------------------------
package esmith;
use strict;
use Errno;
use esmith::ConfigDB;
my $restdb = esmith::ConfigDB->open('/etc/e-smith/restore') ||
esmith::ConfigDB->create('/etc/e-smith/restore');
my $restore = $restdb->get('restore') ||
$restdb->new_record('restore',
{
type => 'status',
start => '0',
finish => '0',
});
$restore->set_prop(state => 'idle');
exit (0);

View File

@ -0,0 +1,58 @@
#!/usr/bin/perl
#----------------------------------------------------------------------
# copyright (C) 2006 Charlie Brady
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
#
#----------------------------------------------------------------------
package esmith;
use warnings;
use strict;
use esmith::ConfigDB;
use esmith::Backup;
my $event = shift;
my $path = shift;
my $confdb = esmith::ConfigDB->open_ro;
my $backup = $confdb->get('backup') or die "No backup db entry found\n";
my $program = $backup->prop('Program');
exit 0 unless $program eq 'CopyFromDisk';
die("Root path to restore from must be provided\n") unless defined $path && -d $path;
chdir $path or die "Could not chdir to $path: $!";
my $backup_db = new esmith::Backup or die "Couldn't create Backup object\n";
my @restore = $backup_db->restore_list;
die "Can't fork: $!" unless defined(my $pid = open(STDIN, "-|"));
if ($pid)
{
# parent - extract files to /
exec(qw(tar -C / -xf -));
}
else
{
# create archive from $path which are to be restored
chroot($path) || die "Can't chroot to $path";
open(STDERR, ">/dev/null");
exec(qw(tar -C / -cf -), @restore);
}

View File

@ -0,0 +1,40 @@
#!/usr/bin/perl -w
#----------------------------------------------------------------------
# copyright (C) 2001 e-smith, inc.
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
#
# Technical support for this program is available from e-smith, inc.
# Please visit our web site www.e-smith.com for details.
#----------------------------------------------------------------------
package esmith;
use strict;
use esmith::ConfigDB;
my $event = shift;
my $cause = shift;
exit 0 if not defined $cause or $cause ne "tape";
my $confdb = esmith::ConfigDB->open_ro;
my $backup = $confdb->get('backup') or die "No backup db entry found\n";
my $device = $backup->prop('Device') || '/dev/st0';
exit 0 unless $device =~ /[sh]t/;
exec("/bin/mt", "-f", $device, "rewind");
die("A problem occurred execing mt");

View File

@ -0,0 +1,31 @@
#!/usr/bin/perl -w
#----------------------------------------------------------------------
# copyright (C) 1999-2003 Mitel Networks Corporation
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
#
# Technical support for this program is available from Mitel Networks
# Please visit our web site www.mitel.com/sme/ for details.
#----------------------------------------------------------------------
use esmith::Backup;
my $backup = new esmith::Backup or die "Couldn't create Backup object\n";
unless ($backup->save_system_files)
{
die "Error saving system files\n"
}
exit 0;

View File

@ -0,0 +1,523 @@
#!/usr/bin/perl -w
#----------------------------------------------------------------------
# copyright (C) 2006-2007 Jean-Paul Leclere <jean-paul@leclere.org>
# copyright (C) 2007 Charlie Brady <charlieb@e-smith.com>
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
#
#----------------------------------------------------------------------
use strict;
use Errno;
use esmith::util;
use esmith::templates;
use File::Copy;
use File::Path qw(make_path remove_tree);
use File::Find;
use POSIX qw(:sys_wait_h strftime);
use File::Glob qw(bsd_glob);
use esmith::ConfigDB;
use esmith::Backup;
use esmith::BlockDevices;
sub ldie;
sub start_dar_killer;
sub run_backup;
my $job = shift || 'DailyBackup';
my $confdb = esmith::ConfigDB->open;
my $backupwk = $confdb->get('backupwk') or die "No backupwk db entry found\n";
my $bkname = strftime '%Y%m%d%H%M%S', localtime;
my $dow = strftime '%w', localtime;
my $ref = "";
my $id = $backupwk->prop('Id') ||
$confdb->get('SystemName')->value . "." . $confdb->get('DomainName')->value;
my $internalinterface = $confdb->get('InternalInterface') or die "No internalinterface db entry found\n";
my $ether = $internalinterface->prop('Name');
my $smbhost = $backupwk->prop('SmbHost');
my $smbshare = $backupwk->prop('SmbShare');
my $smbv1 = $backupwk->prop('SmbV1') || 'disabled';
my $smbhostmac = $backupwk->prop('SmbHostMAC');
my $smbhostdelay = $backupwk->prop('SmbHostDelay') || 300;
my $login = $backupwk->prop('Login');
my $password = $backupwk->prop('Password');
my $setsmax = $backupwk->prop('SetsMax') || 1;
my $daysinset = $backupwk->prop('DaysInSet') || 1;
my $setnum = $backupwk->prop('SetNum'); $setnum = $setsmax unless defined $setnum;
my $incnum = $backupwk->prop('IncNum'); $incnum = ($daysinset-1) unless defined $incnum;
my $timeout = (($backupwk->prop('Timeout') * 3600) - 30) || '88500';
my $inconly = $backupwk->prop('IncOnlyTimeout') || 'no';
my $VFSType = $backupwk->prop('VFSType') || 'cifs';
my $fullday = $backupwk->prop('FullDay'); $fullday = 7 unless defined $fullday;
my $mail = $backupwk->prop('MailNotify') || 'yes';
my $frommail = $backupwk->prop('FromMail') || 'admin-backup';
my $tomail = $backupwk->prop('ToMail') || 'admin';
my $mntdir = $backupwk->prop('Mount') || '/mnt/smb';
$mntdir = "\/$smbshare" if ($VFSType eq 'usb'); # ToDo change to $backupwk->prop('Mount')
my $deleteearly = $backupwk->prop('DeleteEarly') || 'false';
my @backup_excludes = esmith::Backup->excludes;
@backup_excludes = map "\t/$_\n", sort @backup_excludes;
my $report = "From: $frommail\n";
$report .= "To: $tomail\n";
$report .= "Subject: Daily Backup Report: $id\n\n";
$report .= "================================== \n";
$report .= "DAILY BACKUP TO WORKSTATION REPORT \n";
$report .= "================================== \n";
$report .= "Backup of $id started at " .localtime() . "\n";
$report .= "================================== \n";
if (@backup_excludes) {
$report .= "Some parts are excluded of your backup: \n";
$report .= "@backup_excludes";
$report .= "================================== \n";
}
# ping the SMB Host to see if it is awake
$report .= wol ($ether,$smbhost,$smbhostmac,$smbhostdelay);
# mount backup
bmount($mntdir,$smbhost,$smbshare,$VFSType,$smbv1);
# rotating backup indicators
$incnum++;
$incnum = 0 if ($dow == $fullday && $incnum > $daysinset-7) ||
($fullday == 7 && $incnum >= $daysinset);
if ($incnum == 0)
{
$setnum %= $setsmax;
$setnum++;
}
# if no set directory, make it
my $setname = "set$setnum";
my $setdirname = "$mntdir/$id/$setname";
createTree ($setdirname);
$report .= "Destination //$smbhost/$smbshare/$id/$setname\n";
if ( $incnum == 0 )
{
$bkname = "full-" . $bkname;
}
else
{
# if $incnum <> 0 backup should be incremental
# we find correct reference backup for incremental
my $file;
opendir(DIR, $setdirname) or ldie("Can't open dir $setdirname $!");
while (defined($file = readdir(DIR)))
{
next if $file =~ /^\.\.?$/;
if ($file =~ /dar$/)
{
$ref = $file;
}
}
closedir (DIR);
# if no reference do full backup
if ($ref eq "")
{
$incnum = 0;
$report .= "No existing reference backup, will make full backup \n";
$bkname = "full-" . $bkname;
}
else
{
# removing .dar extension
$ref =~ s/\..*\.dar$//;
$ref = "--ref|" . $setdirname . "/" . $ref; # | will be used to split this string in run_backup()
$bkname = "inc-" . sprintf("%03d", $incnum) . "-". $bkname;
}
}
unless ( ( $incnum != 0 ) || ( $fullday == 7 ) || ( $dow == $fullday ) )
{
my $delay = ($fullday - $dow) % 7;
ldie("Not a permitted day for full backup. Aborting...\nNext full backup in $delay days.\n");
}
$report .= "Basename $bkname\n";
# calculate real timeout if we timeout incrementals only.
# timeout of 88500 is a security for aborting backup within 24h
if ( ($ref eq "") && ($inconly eq "yes"))
{
$timeout = 88500;
}
$report .= "Starting the backup with a timeout of ". int ($timeout/(60*60)). " hours\n";
# Expand backup configuration file template
processTemplate ({TEMPLATE_PATH => "/etc/dar/$job.dcf"});
# If this is a new set and delete before backup is in use
# then empty target directory of any .dar files
if (($deleteearly eq 'true') && (($incnum == 0)))
{
foreach my $file (glob("$setdirname/*.dar"))
{
unlink $file or ldie("Error deleting old backup files in $setdirname : $!")
}
}
my $destination = ($deleteearly ne 'true') ? "$mntdir/$id/$bkname" : "$setdirname/$bkname";
# Perform the actual backup
my $rc = run_backup($destination);
if ($rc != 0 && $rc != 11)
{
ldie("Error while running dar: $rc");
}
if ($deleteearly ne 'true') # Not DeleteEarly so move backup to $setdirname
{
if ($incnum == 0) # If this is a new set then empty target directory of any .dar files
{
foreach my $file (glob("$setdirname/*.dar"))
{
unlink $file or ldie("Error deleting old backup files in $setdirname : $!")
}
}
foreach (bsd_glob("$mntdir/$id/*.dar")) # Move the backup files to the set directory
{
ldie("Error while moving backup file $_ to $setdirname : $!")
unless move($_, $setdirname);
}
}
# update dar_manager catalog
updateDarCatalog ("$mntdir/$id");
# Check free disk space
my $df = qx(/bin/df -Ph \"$mntdir\");
if ($df =~ /(\S+)\s+(\S+)\s+(\S+)\s+(\d*%)/)
{
$report .= "Destination disk usage $2, $4 full, $3 available\n";
}
else
{
$report .= "Destination disk space not available\n";
}
# unmount shared folder
system("/bin/umount", "-f", "$mntdir") unless ($VFSType eq 'mnt');
# time now to update backup configuration
$backupwk->set_prop('SetNum', $setnum);
$backupwk->set_prop('IncNum', $incnum);
$report .= "Backup successfully terminated at ".localtime()."\n";
# Send the Workstation Backup report
if ($mail eq 'yes') {sendReport ($report);}
exit (0);
sub ldie
{
my $errmsg = shift;
$report =~ s/Report:/Failed:/;
$report .= "*** No backup allowed or error during backup ***\n";
$report .= $errmsg;
if (($mail eq 'yes') || ($mail eq 'error'))
{
sendReport ($report,$errmsg);
}
if (($VFSType ne 'mnt') && (!checkMount ($mntdir)))
{
system("/bin/umount", "-f", "$mntdir");
}
die($errmsg);
}
sub start_dar_killer
{
my ($darpid, $gracetime) = @_;
my $tick = $gracetime/10;
my $killer = fork;
return $killer if $killer;
POSIX::setsid;
chdir '/';
#fork && exit;
# wait for timeout or backup termination
while ($tick > 0)
{
sleep 10;
$tick--;
exit unless (kill(0, $darpid));
}
if (kill(0, $darpid))
{
while (kill('QUIT', $darpid) != 1)
{
warn "Failed to stop $darpid dar process\n";
}
}
warn "Partial backup stored on backup workstation.\n",
"Session cleanly closed by timeout after $timeout seconds.\n",
"Not an error, backup process will continue next night.\n";
exit;
}
sub run_backup
{
my $dest = shift;
my $data = undef;
my $pid = undef;
my $killerpid = undef;
eval
{
($pid = open INPUT, "-|", "/usr/bin/dar", "-Q", "-asecu", "-az", "--create", "$dest", split(/\|/,$ref), "-B", "/etc/dar/$job.dcf") or ldie("cannot start : $!" );
if ($pid)
{
$killerpid = start_dar_killer($pid, $timeout);
}
$data = do { local($/); <INPUT> };
};
$report .= $data;
if ($killerpid && kill(0, $killerpid))
{
while (kill('TERM', $killerpid) != 1)
{
warn "Failed to kill $killerpid killer process\n";
}
waitpid($killerpid, 0);
}
waitpid($pid, 0);
my $code = WEXITSTATUS($?);
close(INPUT);
return $code;
}
# Copied from /etc/e-smith/web/functions/backup
# TODO: Move to a shared module
sub checkMount
{
# check if $mountdir is mounted
my $mountdir = shift;
$|=1; # Auto-flush
my @res = qx( findmnt $mountdir );
return ( !@res );
}
# Copied from /etc/e-smith/web/functions/backup
# TODO: Move to a shared module
sub dmount
{
# mount dar unit according to dar-workstation configuration
# return nothing if mount successfull
my ($host,$share,$mountdir,$login,$password,$VFSType,$smbv1) = @_;
if ($VFSType eq 'cifs')
{
my $opt= ($smbv1 eq "enabled")? ",vers=1.0": "";
return ( qx(/bin/mount -t cifs "//$host/$share" $mountdir -o credentials=/etc/dar/CIFScredentials,nounix$opt 2>&1) );
}
elsif ($VFSType eq 'nfs')
{
return ( qx(/bin/mount -t nfs -o nolock "$host:/$share" $mountdir 2>&1) );
}
elsif ($VFSType eq 'usb')
{
my $device = "";
my $vollbl = "";
my $devices = esmith::BlockDevices->new ('allowmount' => 'disabled');
my ($valid, $invalid) = $devices->checkBackupDrives(0);
if ( ${$valid}[0] ) {
foreach ( @{$valid} ) {
$vollbl = $devices->label($_);
if ( $share eq "media/$vollbl" ) {
$device = "/dev/$_";
}
}
}
$devices->destroy;
return ( qx (mount $device /$share 2>&1) );
}
else
{
return ("Error while mounting $host/$share : $VFSType not supported.\n");
}
}
sub removeTree
{
my $tree = shift;
if (-d "$tree")
{
eval {remove_tree("$tree")};
ldie("Error while deleting $tree : $@.\n") if $@;
}
return;
}
sub createTree
{
my $tree = shift;
if (! -d "$tree")
{
eval {make_path("$tree")};
ldie("Error while creating $tree : $@. Maybe insufficient rights directory.\n") if $@;
}
return;
}
sub sendReport
{
my $text = shift;
my $error = shift || "";
open (MAIL, "|/var/qmail/bin/qmail-inject")
|| die "Cannot start mail program: $! $error\n";
print MAIL $text;
close(MAIL);
return;
}
sub wol
{
my ($ether,$host,$mac,$delay) = @_;
my $output="";
if (defined($mac) && (system("ping -c1 $host > /dev/null") != 0)) {
$output .= "$host might be asleep, attempting to wake\n";
system("ether-wake -i $ether $mac");
$output .= "Waiting $delay seconds...\n";
sleep $delay;
}
return $output;
}
sub updateDarCatalog
{
# update dar_manager catalog
my $mntbkdir = shift;
my $catalog = "$mntbkdir/dar-catalog";
my %backupfiles = (); # hash of backup files found on the disk.
unless ( -e $catalog) # Create an empty catalog if none found
{
system("/usr/bin/dar_manager", "-Q", "-C", "$catalog") == 0
or ldie("Unable to create dar_manager catalog.\n");
sleep 1; # sleep added to ensure the creation of a valid catalog
}
# find available backups for the server
my $setbackuplist = sub {if($_ =~ /([\w|-]+)-(\d+)\..*\.dar/){$backupfiles{$2} = $File::Find::dir."/$1-$2";}};
find { wanted => \&$setbackuplist, untaint => 1, follow => 1 }, $mntbkdir ;
my @deletions;
my $pid = open (DAR_LIST, "-|", "/usr/bin/dar_manager", "-Q", "-B", "$catalog", "-l") or ldie ("Cannot start : $!");
my $catalogIndex; # Dar refers to each backup by an index
my $oldkey=0; # The key for %backupfiles is the timestamp
while (<DAR_LIST>)
{
next unless ($_ =~ /(\d+).*\s[\w|-]+-(\d+)/);
($catalogIndex, $oldkey) = ($1,$2);
if (defined($backupfiles{$oldkey})) # found on disk and in catalog
{
delete $backupfiles{$oldkey}; # so that it will not be added in the next step.
}
else
{
push @deletions, $catalogIndex; # Will be deleted from the catalog
}
}
waitpid ($pid, 0);
my $err = WEXITSTATUS($?);
close (DAR_LIST);
ldie ("Catalog error : $err") if $err;
# Delete backups from the catalog that were missing on disk in descending order
while (my $catIndex = pop @deletions)
{
system("/usr/bin/dar_manager", "-Q", "-ai", "-B", "$catalog", "-D", "$catIndex") == 0
or ldie("Failed to delete set $catIndex from catalog. $!\n");
sleep 1; # sleep added to ensure the creation of a valid catalog
}
# Add backups that were missing from the catalog in chronological order
foreach my $key (sort keys %backupfiles)
{
next unless ($key > $oldkey); # prevent adding old backups to the catalog
system("/usr/bin/dar_manager", "-Q", "-ai", "-B", "$catalog", "-A", "$backupfiles{$key}") == 0
or ldie("Failed to add set $backupfiles{$key} to catalog. $!\n");
sleep 1; # sleep added to ensure the creation of a valid catalog
}
return;
}
sub bmount
{
my ($mntdir,$host,$share,$VFSType,$smbv1) = @_;
# verify backup directory not already mounted
if (!checkMount ($mntdir))
{
return if ($VFSType eq 'mnt');
ldie("Seems backup directory is already mounted. " .
"It should not happen and maybe there is a zombie process " .
"you must kill, or another backup in progress. \n");
}
else
{
if ($VFSType eq 'mnt')
{
ldie("Seems backup directory is not mounted. " .
"The backup directory must be mounted when using type 'mnt'. \n");
}
}
# create the directory mount point if it does not exist
createTree ($mntdir);
# mount the backup directory
my $err = dmount($host,$share,$mntdir,'','',$VFSType,$smbv1);
ldie("Error while mounting <//$smbhost/$smbshare>\n" . $err) if $err;
# verify $mntdir is mounted
if (checkMount ($mntdir))
{
# The mount should have suceeded, but sometimes it needs more time,
# so sleep and then check again.
sleep 5;
if (checkMount ($mntdir))
{
ldie("Seems backup directory is not really mounted. It should not happen. \
Verify availability of your backup volume. Stopping the backup now.\n");
}
}
return;
}

View File

View File

View File

@ -0,0 +1,945 @@
<lexicon lang="en-us">
<entry>
<base>BACKUP_TITLE</base>
<trans>Backup or restore server data</trans>
</entry>
<entry>
<base>BACKUP_DESC</base>
<trans>
<![CDATA[
<P>The server provides two ways to back up and restore
your server: using your local desktop or a tape drive.</P>
<P>The first method creates a copy of your server configuration and user
data files, and downloads it to your local desktop via your web browser.
Currently your configuration and data files total approximately
<b>$tarsize</b>. The backup file will be somewhat less than this,
depending on how compressible the data are. The \"Verify desktop backup
file\" option can be used to check the integrity of a desktop backup
file.</P>
<P>The tape backup method uses a software package called <I>$module</I>
to back up your entire hard disk to tape every night. This requires a
supported tape drive and a tape that is not write-protected. The backup
is performed automatically at the selected time every night (with a
reminder automatically e-mailed to the administrator during the day).
Currently your hard disk contains <b>$dumpsize</b> of data.</P>
<P>Both restore methods allow you to restore your configuration and user
data files. <b>Ideally, the restore should be performed on a freshly
installed server</b>.</P>
]]>
</trans>
</entry>
<entry>
<base>BACKUP_DESC_DAR</base>
<trans>
<![CDATA[
<P>Three ways are provided to back up and restore your
server: using a tape drive, using a network share or a local
removable disk, or using your local desktop.</P>
<P>Tape Backup. This method uses a software package called <I>$module</I>
to back up your entire hard disk to tape every night. This requires a
supported tape drive and a tape that is not write-protected. The backup
is performed automatically at the selected time every night (with a
reminder automatically e-mailed to the administrator during the day).
Currently your hard disk contains <b>$dumpsize</b> of data.</P>
<P>Workstation backup. This method uses a software package called <I>dar</I>
to back up your server configuration and data files to a network share
or a local removable disk such as a USB disk.
You can manage how many rotating sets of backups are kept,
and how many incremental backups to have in each set.
The backup is performed automatically at the selected time every day. Currently
configuration and data files total approximately <b>$tarsize</b> uncompressed.
Twice the compressed data size must be available on the backup share.</P>
<P>Backup to Desktop. This method creates a copy of your server
configuration and user data files, and downloads it to your
local desktop via your web browser.
Currently your configuration and data files total approximately
<b>$tarsize</b>. The backup file will be somewhat less than this,
depending on how much the data can be compressed.
This file can be used to restore the server from the console if you
copy it to a local removable disk such as a USB disk.</P>
<P>All backup methods allow you to restore your configuration and user
data files. Workstation backup provides individual file restore. <b>Ideally,
full restore should be performed on a freshly installed server</b>.</P>
]]>
</trans>
</entry>
<entry>
<base>BACKUP_CONFIG_STATUS</base>
<trans>Backup configuration and status</trans>
</entry>
<entry>
<base>TAPE_BACKUPS_ENABLED</base>
<trans>
<![CDATA[
Tape backups are currently <b>enabled</b>.
]]>
</trans>
</entry>
<entry>
<base>BACKUPS_RUN_AT</base>
<trans>Regular tape backups will run at: </trans>
</entry>
<entry>
<base>REMINDER_MESSAGE_AT</base>
<trans>Reminder messages will be sent at: </trans>
</entry>
<entry>
<base>TAPE_BACKUPS_DISABLED</base>
<trans>
<![CDATA[
Tape backups are <b>disabled</b>
]]>
</trans>
</entry>
<entry>
<base>DESKTOP_BACKUP</base>
<trans>Backup to desktop</trans>
</entry>
<entry>
<base>DESKTOP_RESTORE</base>
<trans>Restore from desktop</trans>
</entry>
<entry>
<base>DESKTOP_VERIFY</base>
<trans>Verify desktop backup file</trans>
</entry>
<entry>
<base>TAPE_CONFIGURE</base>
<trans>Configure tape backup</trans>
</entry>
<entry>
<base>TAPE_RESTORE</base>
<trans>Restore from tape</trans>
</entry>
<entry>
<base>RESTORE_IN_PROGRESS_BEGAN_AT</base>
<trans>A system restore is in progress. It began at: </trans>
</entry>
<entry>
<base>REFRESH_THIS_DISPLAY</base>
<trans>Refresh this display</trans>
</entry>
<entry>
<base>CONFIGURE_TAPE_BACKUP</base>
<trans>Configure tape backup</trans>
</entry>
<entry>
<base>RESTORE_COMPLETED</base>
<trans>A system restore has completed</trans>
</entry>
<entry>
<base>STARTED_AT</base>
<trans>It began at: </trans>
</entry>
<entry>
<base>FINISHED_AT</base>
<trans>and finished at: </trans>
</entry>
<entry>
<base>YOU_MUST_REBOOT</base>
<trans>
You must reboot the server to activate any configuration changes that were
made as a result of this restore.
</trans>
</entry>
<entry>
<base>REBOOT</base>
<trans>Reboot</trans>
</entry>
<entry>
<base>SELECT_AN_ACTION</base>
<trans>Select an action</trans>
</entry>
<entry>
<base>X_BACKUP_OR_RESTORE</base>
<trans>X Backup or restore server data</trans>
</entry>
<entry>
<base>ERR_PRE_BACKUP</base>
<trans>Error occurred during pre-backup actions.</trans>
</entry>
<entry>
<base>ERR_PRE_RESTORE</base>
<trans>Error occurred during pre-restore actions.</trans>
</entry>
<entry>
<base>ERR_POST_BACKUP</base>
<trans>Error occurred during post-backup actions.</trans>
</entry>
<entry>
<base>RESTORE_SERVER_CONFIG</base>
<trans>Restore server configuration</trans>
</entry>
<entry>
<base>DESKTOP_RESTORE_DESC</base>
<trans>
<![CDATA[
This process will upload a server backup file from your local desktop to your server and restore the configuration and user data files. <B>The restore should be performed on a freshly installed server</B>.
]]>
</trans>
</entry>
<entry>
<base>FREE_SPACE</base>
<trans>
<![CDATA[
You have approximately $tmpfree free space on the server.
Check that desktop backup file is less than $halffree before
commencing the restore.
]]>
</trans>
</entry>
<entry>
<base>MUST_REBOOT_AFTER_RESTORE</base>
<trans>After the restore completes you must reboot the server.</trans>
</entry>
<entry>
<base>FILE_TO_RESTORE</base>
<trans>Backup file to restore from</trans>
</entry>
<entry>
<base>VERIFY_BACKUP_DESC</base>
<trans>
<![CDATA[
<p>This option will display the names of all files
in a previously created desktop backup file. You
can use this option to verify the contents of the
backup file.</p>
]]>
</trans>
</entry>
<entry>
<base>SELECT_BACKUP_FILE</base>
<trans>Select backup file</trans>
</entry>
<entry>
<base>VERIFY</base>
<trans>Verify</trans>
</entry>
<entry>
<base>RESTORE_CANNOT_PROCEED</base>
<trans>Unable to proceed with restore of server configuration</trans>
</entry>
<entry>
<base>ANOTHER_RESTORE_IN_PROGRESS</base>
<trans>Another restore is in progress. Please try again later.</trans>
</entry>
<entry>
<base>RESTORE_IN_PROGRESS</base>
<trans>Restore in progress</trans>
</entry>
<entry>
<base>RESTORE_IN_PROGRESS_DESC</base>
<trans>
After the restore completes you must reboot the server. Your restore is
complete when the words "Restore complete" appear at the bottom of your screen.
</trans>
</entry>
<entry>
<base>FILES_HAVE_BEEN_RESTORED</base>
<trans>The following files and directories have been restored:</trans>
</entry>
<entry>
<base>RESTORE_FAILED_MSG</base>
<trans>Restore failed! There was an error in reading the backup file.</trans>
</entry>
<entry>
<base>RESTORE_COMPLETE</base>
<trans>Restore complete</trans>
</entry>
<entry>
<base>ERR_RESTORING_GID</base>
<trans>Error occurred while restoring gid of 'www'</trans>
</entry>
<entry>
<base>ERR_RESTORING_INITIAL_GRP</base>
<trans>Error occurred while restoring initial group of 'www'.</trans>
</entry>
<entry>
<base>RESTORE_FAILED</base>
<trans>Restore failed! The backup file was incomplete.</trans>
</entry>
<entry>
<base>COULD_NOT_EXEC_PIPELINE</base>
<trans>Could not execute backup pipeline: </trans>
</entry>
<entry>
<base>COULD_NOT_DECODE</base>
<trans>Could not decode backup file: </trans>
</entry>
<entry>
<base>FILES_IN_BACKUP</base>
<trans>The following files are considered in the backup :</trans>
</entry>
<entry>
<base>VERIFY_COMPLETE</base>
<trans>Verification is complete</trans>
</entry>
<entry>
<base>BACKUP_FILE_INCOMPLETE</base>
<trans>The backup file was incomplete</trans>
</entry>
<entry>
<base>ERR_READING_FILE</base>
<trans>There was an error in reading the backup file.</trans>
</entry>
<entry>
<base>ENABLE_DISABLE_TAPE</base>
<trans>Enable/Disable Nightly Tape Backup</trans>
</entry>
<entry>
<base>TAPE_CONFIG_DESC</base>
<trans>
<![CDATA[
<p>Select whether you wish to enable nightly backups. Then indicate the
desired times for the backup and the load tape reminder.</p> <p>The tape
backup requires a supported tape drive. A warning message will be sent to
the administrator at the designated reminder time if the tape drive is
empty.</p>
]]>
</trans>
</entry>
<entry>
<base>ENABLE_TAPE_BACKUP</base>
<trans>Enable tape backup</trans>
</entry>
<entry>
<base>TAPE_BACKUP_TIME</base>
<trans>Tape backup time of day (hour/min)</trans>
</entry>
<entry>
<base>LOAD_TAPE_REMINDER_TIME</base>
<trans>Load tape reminder time of day (hour/min)</trans>
</entry>
<entry>
<base>AM/PM</base>
<trans>AM/PM</trans>
</entry>
<entry>
<base>AM</base>
<trans>AM</trans>
</entry>
<entry>
<base>PM</base>
<trans>PM</trans>
</entry>
<entry>
<base>UPDATE_CONF</base>
<trans>Update</trans>
</entry>
<entry>
<base>UPDATING_TAPE_CONF</base>
<trans>Updating tape backup configuration</trans>
</entry>
<entry>
<base>ERR_INVALID_HOUR</base>
<trans>Error: invalid backup hour: </trans>
</entry>
<entry>
<base>BETWEEN_0_AND_12</base>
<trans>Please choose an hour between 0 and 12.</trans>
</entry>
<entry>
<base>ERR_INVALID_MINUTE</base>
<trans>Error: invalid backup minute: </trans>
</entry>
<entry>
<base>BETWEEN_0_AND_59</base>
<trans>Please choose a minute between 0 and 59.</trans>
</entry>
<entry>
<base>ERR_INVALID_REMINDER_HOUR</base>
<trans>Error: invalid reminder hour: </trans>
</entry>
<entry>
<base>ERR_INVALID_REMINDER_MINUTE</base>
<trans>Error: invalid reminder minute: </trans>
</entry>
<entry>
<base>ERR_CONF_BACKUP</base>
<trans>Error occurred during conf-backup event.</trans>
</entry>
<entry>
<base>SUCCESSFULLY_ENABLED_TAPE</base>
<trans>Successfully enabled tape backups</trans>
</entry>
<entry>
<base>WITH_BACKUP_TIME</base>
<trans>with backup time: </trans>
</entry>
<entry>
<base>WITH_REMINDER_TIME</base>
<trans>and load tape reminder time: </trans>
</entry>
<entry>
<base>SUCCESSFULLY_DISABLED</base>
<trans>Successfully disabled tape backups</trans>
</entry>
<entry>
<base>RESTORE_CONF_FROM_TAPE</base>
<trans>Restore server configuration from tape backup</trans>
</entry>
<entry>
<base>RESTORE_CONF_FROM_TAPE_DESC</base>
<trans>
<![CDATA[
<P>This process will restore the configuration and user data files from a
server tape backup. <B>The restore should be performed on a freshly installed server</B>.</P>
<P>Ensure that you have loaded the desired backup tape into the tape drive
before proceeding.</P>
<P>After the restore completes you must reboot the server.</P>
]]>
</trans>
</entry>
<entry>
<base>RESTORE_FROM_TAPE</base>
<trans>Restore From Tape</trans>
</entry>
<entry>
<base>UNABLE_TO_RESTORE_CONF</base>
<trans>Unable to restore server configuration</trans>
</entry>
<entry>
<base>RESTORING_FROM_TAPE</base>
<trans>Restoring From Tape</trans>
</entry>
<entry>
<base>NOW_RESTORING_FROM_TAPE</base>
<trans>
Your server configuration and user data
files are now being restored from tape.
</trans>
</entry>
<entry>
<base>ERR_RESTORING_FROM_TAPE</base>
<trans>Error occurred restoring files from tape.</trans>
</entry>
<entry>
<base>ERR_UPDATING_CONF_AFTER_TAPE_RESTORE</base>
<trans>Error occurred while updating system configuration after tape
restore.
</trans>
</entry>
<entry>
<base>COULD_NOT_FORK</base>
<trans>Could not fork: </trans>
</entry>
<entry>
<base>SERVER_REBOOT</base>
<trans>Server reboot</trans>
</entry>
<entry>
<base>SERVER_WILL_REBOOT</base>
<trans>Your server will now reboot.</trans>
</entry>
<entry>
<base>NO_UID_FOR_NAME</base>
<trans>Could not get uid for user named: </trans>
</entry>
<entry>
<base>PAGE_REFRESH_IN</base>
<trans><![CDATA[
This page will refresh to the status display in {$sec} seconds, or
click <a href="/server-manager/cgi-bin/backup">here</a>.
]]></trans>
</entry>
<entry>
<base>Backup or restore</base>
<trans>Backup or restore</trans>
</entry>
<entry>
<base>BACKUP_DESKTOP_TOO_BIG</base>
<trans>
<![CDATA[
<div class="error">
Your server has too much data for a reliable backup to desktop.
</div>
]]>
</trans>
</entry>
<entry>
<base>WORKSTN_BACKUPS_DISABLED</base>
<trans>
<![CDATA[
Workstation backups are <b>disabled</b>
]]>
</trans>
</entry>
<entry>
<base>WORKSTN_BACKUPS_ENABLED</base>
<trans>
<![CDATA[
Workstation backups are currently <b>enabled</b>.
]]>
</trans>
</entry>
<entry>
<base>WKBACKUPS_RUN_AT</base>
<trans>Regular workstation backups will run at: </trans>
</entry>
<entry>
<base>WORKSTN_CONFIGURE</base>
<trans>Configure workstation backup</trans>
</entry>
<entry>
<base>WORKSTN_VERIFY</base>
<trans>Verify workstation backup</trans>
</entry>
<entry>
<base>WORKSTN_RESTORE</base>
<trans>Restore from workstation</trans>
</entry>
<entry>
<base>CONFIGURE_WORKSTN_BACKUP</base>
<trans>Configure Workstation Backup</trans>
</entry>
<entry>
<base>ENABLE_DISABLE_WORKSTN</base>
<trans>Enable/Disable Daily Workstation Backup</trans>
</entry>
<entry>
<base>ENABLE_WORKSTN_BACKUP</base>
<trans>Enable Workstation Backup</trans>
</entry>
<entry>
<base>WORKSTN_BACKUP_TIME</base>
<trans>Workstation backup time of day (hour/min)</trans>
</entry>
<entry>
<base>UPDATING_WORKSTN_CONF</base>
<trans>Updating workstation backup configuration</trans>
</entry>
<entry>
<base>SUCCESSFULLY_ENABLED_WORKSTN</base>
<trans>Successfully enabled workstation backups</trans>
</entry>
<entry>
<base>SUCCESSFULLY_DISABLED_WORKSTN</base>
<trans>Successfully disabled workstation backups</trans>
</entry>
<entry>
<base>VERIFY_WORKSTN_BACKUP_FILE</base>
<trans>Verify workstation backup</trans>
</entry>
<entry>
<base>VERIFY_WORKSTN_BACKUP_DESC</base>
<trans>
<![CDATA[
<p>This option will display the names of all files
in a previously created workstation daily backup. You
can use this option to verify the contents of the
backup.<b>You must choose the backup you want to verify</b></p>
<p>Only files flagged with [Saved] are contained in the backup.</p>
<br/>Backup files are verified from shared folder :
]]>
</trans>
</entry>
<entry>
<base>RESTORE_CONF_FROM_WORKSTN</base>
<trans>Restore server configuration from workstation backup</trans>
</entry>
<entry>
<base>RESTORE_CONF_FROM_WORKSTN_DESC</base>
<trans>
<![CDATA[
<p>This process will restore the configuration and user data files from a
Server workstation backup. <b>The restore
should be performed on a freshly installed Server</b>.</p>
<p>Ensure that choose the right backup to restore below
before proceeding.</p>
<p>After the restore completes you must reboot the server.</p>
Backup will be restored from :
]]>
</trans>
</entry>
<entry>
<base>RESTORE_FROM_WORKSTN</base>
<trans>Restore From Workstation</trans>
</entry>
<entry>
<base>RESTORING_FROM_WORKSTN</base>
<trans>Restoring From Workstation</trans>
</entry>
<entry>
<base>NOW_RESTORING_FROM_WORKSTN</base>
<trans>
Your server configuration and user data
files are now being restored from workstation shared folder.
</trans>
</entry>
<entry>
<base>ERR_RESTORING_FROM_WORKSTN</base>
<trans>Error occurred restoring files from workstation.</trans>
</entry>
<entry>
<base>ERR_UPDATING_CONF_AFTER_WORKSTN_RESTORE</base>
<trans>Error occurred while updating system configuration after workstation
restore.
</trans>
</entry>
<entry>
<base>WORKSTN_NAME</base>
<trans>Workstation IP or hostname
</trans>
</entry>
<entry>
<base>WORKSTN_BACKUP_SETTINGS</base>
<trans>Workstation Backup Settings</trans>
</entry>
<entry>
<base>SHARED_FOLDER_NAME</base>
<trans>Backup share
</trans>
</entry>
<entry>
<base>WORKSTN_LOGIN</base>
<trans>Login name
</trans>
</entry>
<entry>
<base>WORKSTATION_BACKUP_DEST</base>
<trans>Backup workstation settings</trans>
</entry>
<entry>
<base>CONFIGURE_WORKSTN_BACKUP_DESC</base>
<trans>You can set the number of
successive backup sets to keep on the workstation, with automatic rotation.
Each set may contain saved data for several consecutive days.
In this case first backup of the set is full backup, others daily backups are
incremental. You can also set a time limit for each backup session or for incremental
backups only. When this limit occurs, backup is cleanly stopped and the next
incremental backup will safely continue with unsaved and modified datas.</trans>
</entry>
<entry>
<base>ERR_INVALID_WORKSTN</base>
<trans>Invalid Workstation IP or Hostname
</trans>
</entry>
<entry>
<base>ERR_INVALID_FOLDER</base>
<trans>Invalid share name
</trans>
</entry>
<entry>
<base>ERR_INVALID_LOGIN</base>
<trans>Invalid Login
</trans>
</entry>
<entry>
<base>ERR_INVALID_PASSWORD</base>
<trans>Invalid Password</trans>
</entry>
<entry>
<base>ERR_ALREADY_MOUNTED</base>
<trans>Backup directory is already mounted</trans>
</entry>
<entry>
<base>ERR_MOUNTING_SMBSHARE</base>
<trans>Unable to mount workstation shared folder</trans>
</entry>
<entry>
<base>ERR_NOT_MOUNTED</base>
<trans>Backup directory is not mounted</trans>
</entry>
<entry>
<base>WORKSTN_NOT_SET</base>
<trans>You must first correctly configure your workstation backup</trans>
</entry>
<entry>
<base>NO_BACKUPS_TO_RESTORE</base>
<trans>There is no backup set on configured workstation shared folder. Verify your configuration settings.</trans>
</entry>
<entry>
<base>NUMBER_OF_SETS</base>
<trans>Number of rotating backup sets</trans>
</entry>
<entry>
<base>NUMBER_OF_FILES_IN_SET</base>
<trans>Daily backups in each set</trans>
</entry>
<entry>
<base>ERR_INVALID_SETS_NUMBER</base>
<trans>Sets number must be 1 or greater</trans>
</entry>
<entry>
<base>ERR_INVALID_FILES_IN_SET_NUMBER</base>
<trans>This number must be 1 or greater. First backup in set is <b>full</b> others are <b>incrementals</b></trans>
</entry>
<entry>
<base>WORKSTN_TIMEOUT</base>
<trans>Optional backup session timeout (hours)</trans>
</entry>
<entry>
<base>INC_ONLY_TIMEOUT</base>
<trans>Don't timeout full backup sessions</trans>
</entry>
<entry>
<base>ERR_INVALID_TIMEOUT</base>
<trans>Maximum backup time must be set between 1 and 24 hours</trans>
</entry>
<entry>
<base>ERR_NO_HOST_DIR</base>
<trans>No directory for your host in shared folder. Maybe your host name is different from backup ones</trans>
</entry>
<entry>
<base>ERROR_READING_FILE</base>
<trans>Error while reading files from</trans>
</entry>
<entry>
<base>WORKSTN_SEL_RESTORE</base>
<trans>Selective file restore from workstation</trans>
</entry>
<entry>
<base>WORKSTN_SELECTIVE_RESTORE</base>
<trans>Workstation selective file restore</trans>
</entry>
<entry>
<base>ALL_BACKUPS</base>
<trans>All backups</trans>
</entry>
<entry>
<base>WORKSTN_SEL_REST_DESC</base>
<trans>
<![CDATA[
This process will restore only specified files and directories. You must first choose
the backup from which the files will be restored. If you don't know in which backup
are the required files, you can select 'All backups' option. <br/><br/>
The next panel will display available files and directories,
so you can choose the ones to restore. To restrict the number of files and directories
displayed in this panel, you have the option to give now a filtering expression,
applied as a regular expression to the displayed names.<br/><br/>
You have the responsibility not to restore files which could break the
functioning of your server.<br/> <br/>Currently, files will be restored from :
]]>
</trans>
</entry>
<entry>
<base>BACKUP_CHOICE</base>
<trans>Selecting files to display</trans>
</entry>
<entry>
<base>SELECT_DATE_BEFORE</base>
<trans>Restore most recent before</trans>
</entry>
<entry>
<base>FILTER_EXPRESSION</base>
<trans>Names filtered by</trans>
</entry>
<entry>
<base>READ_COMPLETE</base>
<trans>
<![CDATA[
You can choose all the directories and files you want to restore in the displayed list
(use ctrl or shift for multiple selection). <br/> <b>Warning :</b> If you select a directory,
all contained files and directories will be restored.<p/>
By default the most recent version of selected files is restored, but if you specify a date
in the format <i>[ [ [yyyy/]mm/]dd-]hh:mm[:ss]</i> the process
will restore only the most recent version modified <b>before the given date</b>.
]]>
</trans>
</entry>
<entry>
<base>ERR_INVALID_SELDATE</base>
<trans>Date format is invalid, must be [ [ [yyyy/]mm/]dd-]hh:mm[:ss]. ie: 2005/12/31-08:23:32 or
10-08:32 or 08:32</trans>
</entry>
<entry>
<base>SELECT_FILES_TO_RESTORE</base>
<trans>Select files to restore</trans>
</entry>
<entry>
<base>ERR_WHILE_UNMOUNTING</base>
<trans>Error occurs when unmounting distant share</trans>
</entry>
<entry>
<base>ERR_DAR_CATALOG</base>
<trans>Error when using Dar catalog</trans>
</entry>
<entry>
<base>COMPRESSION_LEVEL</base>
<trans>Backup compression level [0-9]</trans>
</entry>
<entry>
<base>FULL_ONLY_ON</base>
<trans>Full backup is allowed on</trans>
</entry>
<entry>
<base>ERR_INVALID_COMPRESSION</base>
<trans>Compression level must be set between 0 (no compression) and 9 (maximum compression)</trans>
</entry>
<entry>
<base>DOW</base>
<trans>Sunday Monday Tuesday Wednesday Thursday Friday Saturday Everyday</trans>
</entry>
<entry>
<base>CONFIGURATION_TO_BE_DONE</base>
<trans>Please configure the backup settings.</trans>
</entry>
<entry>
<base>WORKSTN_BACKUP_DESC</base>
<trans>
<![CDATA[
<p>This panel displays the present workstation backup configuration. You can
change it in this panel and the next one.</p><p/>
]]>
</trans>
</entry>
<entry>
<base>WORKSTN_BACKUP_NOT_CONFIGURED</base>
<trans>
<![CDATA[
<p>Presently, workstation backup is not configured. You can set this configuration
with this panel and the next one.</p><p/>
]]>
</trans>
</entry>
<entry>
<base>WORKSTN_BACKUP_ENABLED</base>
<trans>Backup is </trans>
</entry>
<entry>
<base>WORKSTN_BACKUP_USB</base>
<trans>Backup is made on local removable disk</trans>
</entry>
<entry>
<base>WORKSTN_BACKUP_MNT</base>
<trans>Backup is made on mounted disk</trans>
</entry>
<entry>
<base>WORKSTN_BACKUP_HOST</base>
<trans>Backup is made on LAN workstation </trans>
</entry>
<entry>
<base>WORKSTN_BACKUP_VFSTYPE</base>
<trans> via </trans>
</entry>
<entry>
<base>WORKSTN_BACKUP_SHARE</base>
<trans>Destination backup share folder is </trans>
</entry>
<entry>
<base>WORKSTN_BACKUP_TOD</base>
<trans>Daily backup occurs at </trans>
</entry>
<entry>
<base>LOGIN</base>
<trans>Login is </trans>
</entry>
<entry>
<base>PASSWORD</base>
<trans>Password is </trans>
</entry>
<entry>
<base>WORKSTN_BACKUP_SETSNUM</base>
<trans>Number of rotating backup sets is </trans>
</entry>
<entry>
<base>WORKSTN_BACKUP_DAYSINSET</base>
<trans>Number of daily backups contained in each set is </trans>
</entry>
<entry>
<base>WORKSTN_BACKUP_COMPRESSION</base>
<trans>Compression level (0-9) of backup is </trans>
</entry>
<entry>
<base>WORKSTN_BACKUP_TIMEOUT</base>
<trans>Each daily backup session is cleanly timed out after </trans>
</entry>
<entry>
<base>WORKSTN_BACKUP_INCONLY_TIMEOUT</base>
<trans>except full backups which are cleanly timed out after 24 hours</trans>
</entry>
<entry>
<base>WORKSTN_FULL_BACKUP_EVERYDAY</base>
<trans>Full backup sessions (new backup set) are allowed everyday</trans>
</entry>
<entry>
<base>WORKSTN_FULL_BACKUP_DAY</base>
<trans>Full backup session (new backup sets) is allowed only on</trans>
</entry>
<entry>
<base>WORKSTATION_BACKUP_SETCONF</base>
<trans>Create or modify workstation backup configuration</trans>
</entry>
<entry>
<base>SELECT_VFS_TYPE</base>
<trans>Select the type of share for backup destination</trans>
</entry>
<entry>
<base>ERR_NO_USB_DISK</base>
<trans>Error : No removable disk available. Please connect a removable disk or select another type of workstation backup.</trans>
</entry>
<entry>
<base>ERR_NO_MOUNTED_DISK</base>
<trans>Error : No mounted disk available. Please mount a disk or select another type of workstation backup.</trans>
</entry>
<entry>
<base>HOURS</base>
<trans>hours.</trans>
</entry>
<entry>
<base>ERR_NO_FULL_BACKUP</base>
<trans>Aborting restore because needed full backup is missing or unreadable.</trans>
</entry>
<entry>
<base>ERR_NO_INC_BACKUP</base>
<trans>Aborting restore because the set has missing or unreadable incremental backup number</trans>
</entry>
<entry>
<base>CHECK_TO_VERIFY_FULL_RESTORE</base>
<trans>Check here to test integrity of all backups needed for a full restore with the selected backup </trans>
</entry>
<entry>
<base>TESTING_NEEDED_BACKUPS_FOR_RESTORE</base>
<trans>Testing all backups needed for a full restore with selected backup</trans>
</entry>
<entry>
<base>TESTED_BACKUP</base>
<trans>Testing integrity of backup</trans>
</entry>
<entry>
<base>RESTORE_VERIFY_FAILED</base>
<trans>Verify integrity failed</trans>
</entry>
<entry>
<base>CHECK_INTEGRITY_WARNING</base>
<trans>Warning : For large backups, checking integrity may be a long task and should be made with daily workstation backup disabled.</trans>
</entry>
<entry>
<base>cifs</base>
<trans>cifs</trans>
</entry>
<entry>
<base>nfs</base>
<trans>nfs</trans>
</entry>
<entry>
<base>local removable disk</base>
<trans>Local removable disk</trans>
</entry>
<entry>
<base>Mounted disk</base>
<trans>Mounted disk</trans>
</entry>
<entry>
<base>ERROR_WHEN_TESTING_REMOTE_SERVER</base>
<trans>The parameters have been saved, however the remote host is not reachable, please check your settings.</trans>
</entry>
<entry>
<base>DO_NOT_RESTORE_BIN_SBIN_LIB_LIB64_FROM_SME9</base>
<trans>If you restore from Koozali SME Server 9 or before, pay attention that some folders in the system are now symlinks. Basic backup configuration does not include /bin, /lib, /lib64, /sbin, /var/lock and /var/run. If you have added them for files in their subdirectories, we will prevent the restoration of those folders to prevent dar from replacing those symlinks and leave the system unusable. Those additions are, however, not recommended as they are at risk to overwrite files provides by rpms.</trans>
</entry>
<entry>
<base>SMBV1</base>
<trans>Mount as legacy SMB v1 share (unsecure, not recommended).</trans>
</entry>
</lexicon>

View File

@ -0,0 +1 @@
PERMS=0600

View File

@ -0,0 +1,46 @@
{
use POSIX;
use Locale::gettext;
use esmith::I18N;
my $i18n = new esmith::I18N;
$i18n->setLocale('backup');
$OUT = '';
my $status = $backup{status} || 'disabled';
unless ($status eq 'enabled')
{
$OUT .= "# " . gettext("Backup task is disabled");
return;
}
# FIXME - "mt tell" won't work with all backup devices
my $device = $backup{Device} || "/dev/nst0";
my $reminderTime = $backup{reminderTime} || "14:00";
my ($reminderHour, $reminderMin) = split (":", $reminderTime, -1);
my $reminderEmail = $backup{reminderEmail} || 'admin';
# remove leading zeros from minutes
$reminderMin =~ s/00/0/;
$OUT .=
"$reminderMin $reminderHour * * * root"
. " /bin/mt -f $device status 2>&1 | grep ONLINE > /dev/null ||"
. ' echo "' . gettext("Remember to load the backup tape!") . '"'
. ' | mail -s "' . gettext("Remember to load the backup tape!") . '"'
. " $reminderEmail\n";
my $backupTime = $backup{backupTime} || "2:00";
my ($backupHour, $backupMin) = split (":", $backupTime, -1);
# remove leading zeros from minutes
$backupMin =~ s/00/0/;
$OUT .=
"$backupMin $backupHour * * * root"
. " /sbin/e-smith/do_backup"
}

View File

@ -0,0 +1,30 @@
{
$OUT = '';
my $status = $backupwk{status};
if (defined $status && $status eq 'enabled')
{
# configure backup time and reminder times from the configuration
# database
my $backupMin;
my $backupHour;
my $backupTime = $backupwk{BackupTime} || "1:00";
($backupHour, $backupMin) = split (":", $backupTime, -1);
# remove leading zeros from minutes
$backupMin =~ s/00/0/;
$OUT .="$backupMin $backupHour * * * root"
. " /sbin/e-smith/do_backupwk"
}
else
{
$OUT .= "# Workstation Backup task is disabled";
}
}

View File

@ -0,0 +1,2 @@
username={$backupwk{'Login'}}
password={$backupwk{'Password'}}

View File

@ -0,0 +1,6 @@
{
$level = $backupwk{Compression} || 0;
$prog = $backupwk{CompressionProg} || 'gzip';
$OUT = ($level eq '0' or $prog eq 'none') ? "#Compression off" : "--$prog=$level"
}

View File

@ -0,0 +1 @@
--empty-dir

View File

@ -0,0 +1 @@
--fs-root /

View File

@ -0,0 +1,8 @@
{
use esmith::Backup;
my @backup_list = esmith::Backup->restore_list;
foreach my $dir ( @backup_list ) {
$OUT .= "--go-into $dir\n";
}
}

View File

@ -0,0 +1,7 @@
{
use esmith::Backup;
my @exclusion_list = esmith::Backup->excludes;
foreach my $dir ( @exclusion_list ) {
$OUT .= "--prune $dir\n";
}
}

View File

@ -0,0 +1,191 @@
{
($backupwk{Compression} || '0') eq '0' ? "#Compression off\n" :
'--exclude-compression "*.0"
--exclude-compression "*.000"
--exclude-compression "*.7z"
--exclude-compression "*.a00"
--exclude-compression "*.a01"
--exclude-compression "*.a02"
--exclude-compression "*.ace"
--exclude-compression "*.ain"
--exclude-compression "*.alz"
--exclude-compression "*.apz"
--exclude-compression "*.ar"
--exclude-compression "*.arc"
--exclude-compression "*.ari"
--exclude-compression "*.arj"
--exclude-compression "*.ark"
--exclude-compression "*.asf"
--exclude-compression "*.avi"
--exclude-compression "*.axx"
--exclude-compression "*.b64"
--exclude-compression "*.ba"
--exclude-compression "*.bh"
--exclude-compression "*.boo"
--exclude-compression "*.bz"
--exclude-compression "*.bz2"
--exclude-compression "*.bzip"
--exclude-compression "*.bzip2"
--exclude-compression "*.c00"
--exclude-compression "*.c01"
--exclude-compression "*.c02"
--exclude-compression "*.car"
--exclude-compression "*.cb7"
--exclude-compression "*.cbr"
--exclude-compression "*.cbt"
--exclude-compression "*.cbz"
--exclude-compression "*.cp9"
--exclude-compression "*.cpgz"
--exclude-compression "*.cpt"
--exclude-compression "*.dar"
--exclude-compression "*.dd"
--exclude-compression "*.deb"
--exclude-compression "*.dgc"
--exclude-compression "*.dist"
--exclude-compression "*.divx"
--exclude-compression "*.ecs"
--exclude-compression "*.efw"
--exclude-compression "*.f"
--exclude-compression "*.fdp"
--exclude-compression "*.flac"
--exclude-compression "*.gca"
--exclude-compression "*.gif"
--exclude-compression "*.gz"
--exclude-compression "*.gzi"
--exclude-compression "*.gzip"
--exclude-compression "*.ha"
--exclude-compression "*.hbc"
--exclude-compression "*.hbc2"
--exclude-compression "*.hbe"
--exclude-compression "*.hki"
--exclude-compression "*.hki1"
--exclude-compression "*.hki2"
--exclude-compression "*.hki3"
--exclude-compression "*.hpk"
--exclude-compression "*.hyp"
--exclude-compression "*.ice"
--exclude-compression "*.ipg"
--exclude-compression "*.ipk"
--exclude-compression "*.ish"
--exclude-compression "*.iso"
--exclude-compression "*.j"
--exclude-compression "*.jgz"
--exclude-compression "*.jic"
--exclude-compression "*.jpeg"
--exclude-compression "*.jpg"
--exclude-compression "*.kgb"
--exclude-compression "*.lbr"
--exclude-compression "*.lemon"
--exclude-compression "*.lha"
--exclude-compression "*.lnx"
--exclude-compression "*.lqr"
--exclude-compression "*.lz"
--exclude-compression "*.lzh"
--exclude-compression "*.lzm"
--exclude-compression "*.lzma"
--exclude-compression "*.lzo"
--exclude-compression "*.lzx"
--exclude-compression "*.md"
--exclude-compression "*.mint"
--exclude-compression "*.mp3"
--exclude-compression "*.mpeg"
--exclude-compression "*.mpg"
--exclude-compression "*.mpkg"
--exclude-compression "*.mzp"
--exclude-compression "*.oga"
--exclude-compression "*.ogg"
--exclude-compression "*.ogv"
--exclude-compression "*.ogx"
--exclude-compression "*.p7m"
--exclude-compression "*.package"
--exclude-compression "*.pae"
--exclude-compression "*.pak"
--exclude-compression "*.paq6"
--exclude-compression "*.paq7"
--exclude-compression "*.paq9"
--exclude-compression "*.par"
--exclude-compression "*.par2"
--exclude-compression "*.pbi"
--exclude-compression "*.pcv"
--exclude-compression "*.pea"
--exclude-compression "*.pf"
--exclude-compression "*.pim"
--exclude-compression "*.pit"
--exclude-compression "*.piz"
--exclude-compression "*.pkg"
--exclude-compression "*.png"
--exclude-compression "*.pup"
--exclude-compression "*.puz"
--exclude-compression "*.pwa"
--exclude-compression "*.qda"
--exclude-compression "*.r00"
--exclude-compression "*.r01"
--exclude-compression "*.r02"
--exclude-compression "*.r03"
--exclude-compression "*.ra"
--exclude-compression "*.rar"
--exclude-compression "*.rev"
--exclude-compression "*.rk"
--exclude-compression "*.rm"
--exclude-compression "*.rnc"
--exclude-compression "*.rp9"
--exclude-compression "*.rpm"
--exclude-compression "*.rte"
--exclude-compression "*.rz"
--exclude-compression "*.rzs"
--exclude-compression "*.s00"
--exclude-compression "*.s01"
--exclude-compression "*.s02"
--exclude-compression "*.s7z"
--exclude-compression "*.sar"
--exclude-compression "*.sdc"
--exclude-compression "*.sdn"
--exclude-compression "*.sea"
--exclude-compression "*.sen"
--exclude-compression "*.sfs"
--exclude-compression "*.sfx"
--exclude-compression "*.shar"
--exclude-compression "*.shk"
--exclude-compression "*.shr"
--exclude-compression "*.sit"
--exclude-compression "*.sitx"
--exclude-compression "*.spt"
--exclude-compression "*.sqx"
--exclude-compression "*.sqz"
--exclude-compression "*.tar"
--exclude-compression "*.tbz"
--exclude-compression "*.tbz2"
--exclude-compression "*.tg"
--exclude-compression "*.tgz"
--exclude-compression "*.tlz"
--exclude-compression "*.tlzma"
--exclude-compression "*.tz"
--exclude-compression "*.uc2"
--exclude-compression "*.uha"
--exclude-compression "*.vem"
--exclude-compression "*.vsi"
--exclude-compression "*.wad"
--exclude-compression "*.war"
--exclude-compression "*.wma"
--exclude-compression "*.wmv"
--exclude-compression "*.wot"
--exclude-compression "*.xef"
--exclude-compression "*.xez"
--exclude-compression "*.xmcdz"
--exclude-compression "*.xpi"
--exclude-compression "*.xx"
--exclude-compression "*.y"
--exclude-compression "*.yz"
--exclude-compression "*.z"
--exclude-compression "*.z01"
--exclude-compression "*.z02"
--exclude-compression "*.z03"
--exclude-compression "*.z04"
--exclude-compression "*.zap"
--exclude-compression "*.zfsendtotarget"
--exclude-compression "*.zip"
--exclude-compression "*.zipx"
--exclude-compression "*.zix"
--exclude-compression "*.zoo"
--exclude-compression "*.zz"'
}

View File

@ -0,0 +1 @@
--noconf

View File

@ -0,0 +1 @@
--no-warn

View File

@ -0,0 +1,3 @@
{
($backupwk{Slice} || '700M') eq '700M' ? "--slice 700M\n" : "--slice $backupwk{Slice}\n"
}

View File

@ -0,0 +1,4 @@
<Location /server-manager/cgi-bin/backup>
SetEnv force-proxy-request-1.0 1
</Location>

View File

@ -0,0 +1 @@
1053551285=backup_record|BackupType|desktop|StartEpochTime|1053551285|EndEpochTime|1053551299|Result|0

View File

@ -0,0 +1,54 @@
root:x:0:root,admin
bin:x:1:root,bin,daemon
daemon:x:2:root,bin,daemon
sys:x:3:root,bin,adm
adm:x:4:root,adm,daemon
tty:x:5:
disk:x:6:root
lp:x:7:daemon,lp
mem:x:8:
kmem:x:9:
wheel:x:10:root
mail:x:12:mail
news:x:13:news
uucp:x:14:uucp
man:x:15:
floppy:x:19:
games:x:20:
slocate:x:21:
utmp:x:22:
squid:x:23:
mysql:x:27:
gopher:x:30:
rpm:x:37:
ntp:x:38:
dip:x:40:
apache:x:48:
ftp:x:50:
dns:x:53:
ldap:x:55:
lock:x:54:
vcsa:x:69:
sshd:x:74:
pcap:x:77:
fax:x:78:
nobody:x:99:
users:x:100:
admin:x:101:www
www:x:102:admin
public:x:103:
nofiles:x:400:
qmail:x:401:
qmailscan:x:407:
jabber:x:408:
dnscache:x:410:
dnslog:x:411:
nutups:x:420:
stunnel:x:451:
trend:x:452:
shared:x:500:public,admin,www
imaplog:x:1001:
smelog:x:1002:
cvmlog:x:1003:
spamd:x:1005:
smelastsys:x:2999:

View File

@ -0,0 +1,58 @@
root:x:0:admin,root
bin:x:1:bin,daemon,root
daemon:x:2:bin,daemon,root
sys:x:3:adm,bin,root
adm:x:4:adm,daemon,root
tty:x:5:
disk:x:6:root
lp:x:7:daemon,lp
mem:x:8:
kmem:x:9:
wheel:x:10:root
mail:x:12:mail
news:x:13:news
uucp:x:14:uucp
man:x:15:
floppy:x:19:
games:x:20:
slocate:x:21:
utmp:x:22:
squid:x:23:
mysql:x:27:
gopher:x:30:
rpm:x:37:
ntp:x:38:
dip:x:40:
apache:x:48:
ftp:x:50:
dns:x:53:
lock:x:54:
ldap:x:55:
vcsa:x:69:
sshd:x:74:
pcap:x:77:
fax:x:78:
nobody:x:99:
users:x:100:
admin:x:101:test,www
www:x:102:admin
public:x:103:
nofiles:x:400:
qmail:x:401:
qmailscan:x:407:
jabber:x:408:
dnscache:x:410:
dnslog:x:411:
nutups:x:420:
stunnel:x:451:
trend:x:452:
shared:x:500:admin,public,test,tester,www
imaplog:x:1001:
smelog:x:1002:
cvmlog:x:1003:
spamd:x:1005:
smelastsys:x:2999:
tester:x:5001:
testgroup:x:5002:admin,www
test:x:5003:
vita-weat$:x:5004:

View File

@ -0,0 +1,48 @@
root:x:0:root,admin
bin:x:1:root,bin,daemon
daemon:x:2:root,bin,daemon
sys:x:3:root,bin,adm
adm:x:4:root,adm,daemon
tty:x:5:
disk:x:6:root
lp:x:7:daemon,lp
mem:x:8:
kmem:x:9:
wheel:x:10:root
mail:x:12:mail
news:x:13:news
uucp:x:14:uucp
man:x:15:
floppy:x:19:
games:x:20:
slocate:x:21:
utmp:x:22:
squid:x:23:
named:x:25:
mysql:x:27:
gopher:x:30:
rpm:x:37:
ntp:x:38:
dip:x:40:
apache:x:48:
ftp:x:50:
dns:x:53:
ldap:x:55:
lock:x:54:
vcsa:x:69:
pcap:x:77:
nobody:x:99:
users:x:100:
admin:x:101:www,test
www:x:102:admin
public:x:103:
nofiles:x:400:
qmail:x:401:
qmailscan:x:407:
trend:x:408:
shared:x:500:public,admin,www,tester,test
nutups:x:420:
tester:x:5001:
testgroup:x:5002:admin,www
test:x:5003:
vita-weat$:x:5004:

View File

@ -0,0 +1,46 @@
root:x:0:0:root:/root:/bin/bash
bin:x:1:1:bin:/bin:/sbin/nologin
daemon:x:2:2:daemon:/sbin:/sbin/nologin
adm:x:3:4:adm:/var/adm:/sbin/nologin
lp:x:4:7:lp:/var/spool/lpd:/sbin/nologin
mail:x:8:12:mail:/var/spool/mail:/sbin/nologin
news:x:9:13:news:/var/spool/news:
uucp:x:10:14:uucp:/var/spool/uucp:/sbin/nologin
operator:x:11:0:operator:/root:/sbin/nologin
games:x:12:100:games:/usr/games:/sbin/nologin
gopher:x:13:30:gopher:/var/gopher:/sbin/nologin
ftp:x:14:50:FTP User:/var/ftp:/sbin/nologin
squid:x:23:23::/var/spool/squid:/dev/null
mysql:x:27:27:MySQL Server:/var/lib/mysql:/bin/bash
rpm:x:37:37::/var/lib/rpm:/bin/bash
ntp:x:38:38::/etc/ntp:/sbin/nologin
apache:x:48:48:Apache:/var/www:/bin/false
dns:x:53:53:DNS:/home/dns:/bin/false
ldap:x:55:55:LDAP User:/var/lib/ldap:/bin/false
vcsa:x:69:69:virtual console memory owner:/dev:/sbin/nologin
sshd:x:74:74:Privilege-separated SSH:/var/empty/sshd:/sbin/nologin
pcap:x:77:77::/var/arpwatch:/sbin/nologin
fax:x:78:78:mgetty fax spool user:/var/spool/fax:/sbin/nologin
nobody:x:99:99:Nobody:/:/sbin/nologin
www:x:100:101:e-smith web server:/home/e-smith:/bin/false
admin:x:101:101:e-smith administrator:/home/e-smith:/sbin/e-smith/console
public:x:102:103:e-smith guest:/home/e-smith:/bin/false
alias:x:400:400::/var/qmail/alias:/bin/false
qmaild:x:401:400::/var/qmail:/bin/false
qmaill:x:402:400::/var/qmail:/bin/false
qmailp:x:403:400::/var/qmail:/bin/false
qmailq:x:404:401::/var/qmail:/bin/false
qmailr:x:405:401::/var/qmail:/bin/false
qmails:x:406:401::/var/qmail:/bin/false
qmailscan:x:407:407::/var/spool/qmailscan:/bin/false
jabber:x:408:408::/var/spool/jabber:/bin/bash
dnscache:x:410:410:DNScache user:/var/service/dnscache:/bin/false
dnslog:x:411:411:DNScache log user:/var/service/dnscache/log:/bin/false
nutups:x:420:420::/home/nutups:/bin/bash
stunnel:x:451:451:chrooted stunnel user user:/var/log/imap/ssl:/bin/false
trend:x:452:452:trend virus scanner:/home/trend:/bin/bash
imaplog:x:1001:1001:imap output log user:/var/log/imap:/bin/false
smelog:x:1002:1002:smelog log user:/var/log/smelog:/bin/false
cvmlog:x:1003:1003:cvm output log user:/var/log/imap:/bin/false
spamd:x:1005:1005:spamassassin daemon user:/var/service/spamd:/bin/false
smelastsys:x:2999:2999:sme last system user marker:/tmp:/bin/false

View File

@ -0,0 +1,50 @@
root:x:0:0:root:/root:/bin/bash
bin:x:1:1:bin:/bin:/sbin/nologin
daemon:x:2:2:daemon:/sbin:/sbin/nologin
adm:x:3:4:adm:/var/adm:/sbin/nologin
lp:x:4:7:lp:/var/spool/lpd:/sbin/nologin
mail:x:8:12:mail:/var/spool/mail:/sbin/nologin
news:x:9:13:news:/var/spool/news:
uucp:x:10:14:uucp:/var/spool/uucp:/sbin/nologin
operator:x:11:0:operator:/root:/sbin/nologin
games:x:12:100:games:/usr/games:/sbin/nologin
gopher:x:13:30:gopher:/var/gopher:/sbin/nologin
ftp:x:14:50:FTP User:/var/ftp:/sbin/nologin
squid:x:23:23::/var/spool/squid:/dev/null
mysql:x:27:27:MySQL Server:/var/lib/mysql:/bin/bash
rpm:x:37:37::/var/lib/rpm:/bin/bash
ntp:x:38:38::/etc/ntp:/sbin/nologin
apache:x:48:48:Apache:/var/www:/bin/false
dns:x:53:53:DNS:/home/dns:/bin/false
ldap:x:55:55:LDAP User:/var/lib/ldap:/bin/false
vcsa:x:69:69:virtual console memory owner:/dev:/sbin/nologin
sshd:x:74:74:Privilege-separated SSH:/var/empty/sshd:/sbin/nologin
pcap:x:77:77::/var/arpwatch:/sbin/nologin
fax:x:78:78:mgetty fax spool user:/var/spool/fax:/sbin/nologin
nobody:x:99:99:Nobody:/:/sbin/nologin
www:x:100:101:e-smith web server:/home/e-smith:/bin/false
admin:x:101:101:e-smith administrator:/home/e-smith:/sbin/e-smith/console
public:x:102:103:e-smith guest:/home/e-smith:/bin/false
alias:x:400:400::/var/qmail/alias:/bin/false
qmaild:x:401:400::/var/qmail:/bin/false
qmaill:x:402:400::/var/qmail:/bin/false
qmailp:x:403:400::/var/qmail:/bin/false
qmailq:x:404:401::/var/qmail:/bin/false
qmailr:x:405:401::/var/qmail:/bin/false
qmails:x:406:401::/var/qmail:/bin/false
qmailscan:x:407:407::/var/spool/qmailscan:/bin/false
jabber:x:408:408::/var/spool/jabber:/bin/bash
dnscache:x:410:410:DNScache user:/var/service/dnscache:/bin/false
dnslog:x:411:411:DNScache log user:/var/service/dnscache/log:/bin/false
nutups:x:420:420::/home/nutups:/bin/bash
stunnel:x:451:451:chrooted stunnel user user:/var/log/imap/ssl:/bin/false
trend:x:452:452:trend virus scanner:/home/trend:/bin/bash
imaplog:x:1001:1001:imap output log user:/var/log/imap:/bin/false
smelog:x:1002:1002:smelog log user:/var/log/smelog:/bin/false
cvmlog:x:1003:1003:cvm output log user:/var/log/imap:/bin/false
spamd:x:1005:1005:spamassassin daemon user:/var/service/spamd:/bin/false
smelastsys:x:2999:2999:sme last system user marker:/tmp:/bin/false
tester:x:5001:5001:t t:/home/e-smith/files/users/tester:/bin/sshell
testgroup:x:5002:5002:for testing.:/home/e-smith:/bin/false
test:x:5003:5003:test:/home/e-smith/files/ibays/test/files:/bin/false
vita-weat$:x:5004:5004:Hostname account for vita-weat$:/noexistingpath:/bin/false

View File

@ -0,0 +1,40 @@
root:x:0:0:root:/root:/bin/bash
bin:x:1:1:bin:/bin:/sbin/nologin
daemon:x:2:2:daemon:/sbin:/sbin/nologin
adm:x:3:4:adm:/var/adm:/sbin/nologin
lp:x:4:7:lp:/var/spool/lpd:/sbin/nologin
mail:x:8:12:mail:/var/spool/mail:/sbin/nologin
news:x:9:13:news:/var/spool/news:
uucp:x:10:14:uucp:/var/spool/uucp:/sbin/nologin
operator:x:11:0:operator:/root:/sbin/nologin
games:x:12:100:games:/usr/games:/sbin/nologin
gopher:x:13:30:gopher:/var/gopher:/sbin/nologin
ftp:x:14:50:FTP User:/var/ftp:/sbin/nologin
squid:x:23:23::/var/spool/squid:/dev/null
named:x:25:25:Named:/var/named:/bin/false
mysql:x:27:27:MySQL Server:/var/lib/mysql:/bin/bash
rpm:x:37:37::/var/lib/rpm:/bin/bash
ntp:x:38:38::/etc/ntp:/sbin/nologin
apache:x:48:48:Apache:/var/www:/bin/false
dns:x:53:53:DNS:/home/dns:/bin/false
ldap:x:55:55:LDAP User:/var/lib/ldap:/bin/false
vcsa:x:69:69:virtual console memory owner:/dev:/sbin/nologin
pcap:x:77:77::/var/arpwatch:/sbin/nologin
nobody:x:99:99:Nobody:/:/sbin/nologin
www:x:100:101:e-smith web server:/home/e-smith:/bin/false
admin:x:101:101:e-smith administrator:/home/e-smith:/sbin/e-smith/console
public:x:102:103:e-smith guest:/home/e-smith:/bin/false
alias:x:400:400::/var/qmail/alias:/bin/false
qmaild:x:401:400::/var/qmail:/bin/false
qmaill:x:402:400::/var/qmail:/bin/false
qmailp:x:403:400::/var/qmail:/bin/false
qmailq:x:404:401::/var/qmail:/bin/false
qmailr:x:405:401::/var/qmail:/bin/false
qmails:x:406:401::/var/qmail:/bin/false
qmailscan:x:407:407::/var/spool/qmailscan:/bin/false
trend:x:408:408:trend virus scanner:/home/trend:/bin/bash
nutups:x:420:420::/home/nutups:/bin/bash
tester:x:5001:5001:t t:/home/e-smith/files/users/tester:/bin/sshell
testgroup:x:5002:5002:for testing.:/home/e-smith:/bin/false
test:x:5003:5003:test:/home/e-smith/files/ibays/test/files:/bin/false
vita-weat$:x:5004:5004:Hostname account for vita-weat$:/noexistingpath:/bin/false

File diff suppressed because it is too large Load Diff

0
root/mnt/smb/.gitignore vendored Normal file
View File

View File

@ -0,0 +1,3 @@
package esmith::console::perform_backup;
use esmith::console::perform_backup;
return new esmith::console::perform_backup;

View File

@ -0,0 +1,3 @@
package esmith::console::perform_restore;
use esmith::console::perform_restore;
return new esmith::console::perform_restore;

113
root/sbin/e-smith/do_backup Normal file
View File

@ -0,0 +1,113 @@
#! /usr/bin/perl -w
#----------------------------------------------------------------------
# copyright (C) 2002 Mitel Networks Corporation
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
#
# Technical support for this program is available from Mitel Networks
# Please visit our web site www.mitel.com/sme/ for details.
#----------------------------------------------------------------------
use strict;
use esmith::ConfigDB;
use esmith::BackupHistoryDB;
use esmith::Backup;
#use esmith::lockfile;
# lock file.. see bug 9127
my $backup_lock;
$ENV{PATH} = "/sbin/e-smith:/sbin:/bin:/usr/bin";
my $conf = esmith::ConfigDB->open || die("Could not open config db\n");
# set lock.. if not, exit
unless (SetLock()) {
die "Error: failed to create lock file.. is a backup already running?";
}
my $backup = $conf->get('backup');
my $status = $backup->prop('status') || 'disabled';
my $program = $backup->prop('Program') || 'flexbackup';
my $backupType = $backup->prop('BackupType') || 'tape';
unless ($status eq 'enabled')
{
print "Backup is disabled\n";
exit 0;
}
my $backups = esmith::BackupHistoryDB->open
|| die("Could not open backup history db\n");
my $now = time();
die "backup not allowed twice at the same date/time, delayed to next day\n" if $backups->get($now);
my $backup_rec = $backups->new_record($now, { type => 'backup_record' });
$backup_rec->set_prop('StartEpochTime', "$now");
$backup_rec->set_prop('BackupType', $backupType);
if ($status = system(qw(signal-event pre-backup), $backupType))
{
exit bad_exit($backup_rec, "pre-backup", $status);
}
if ($status = system("/etc/e-smith/events/actions/tape-backup-$program"))
{
exit bad_exit($backup_rec, "backup", $status);
}
if ($status = system(qw(signal-event post-backup), $backupType))
{
exit bad_exit($backup_rec, "post-backup", $status);
}
$now = time();
$backup_rec->set_prop('EndEpochTime', "$now");
$backup_rec->set_prop('Result', "$status");
# remove lock
RemoveLock();
exit 0;
sub bad_exit
{
my ($backup_rec, $phase, $status) = @_;
my $now = time();
warn("Backup terminated: $phase failed - status: $status\n");
$backup_rec->set_prop('EndEpochTime', "$now");
$backup_rec->set_prop('Result', "$phase:$status");
# remove lock
RemoveLock();
return $status / 256;
}
# subs to set and remove lock on backup
sub SetLock
{
print "Setting backup lock file\n";
$backup_lock = esmith::Backup::set_lock;
return $backup_lock;
}
sub RemoveLock
{
if (defined($backup_lock))
{
print "Removing backup lock file\n";
esmith::Backup::remove_lock($backup_lock);
$backup_lock = undef;
}
}

View File

@ -0,0 +1,109 @@
#! /usr/bin/perl -w
#----------------------------------------------------------------------
# copyright (C) 2006 SME Server
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
#
#----------------------------------------------------------------------
use strict;
use esmith::ConfigDB;
use esmith::BackupHistoryDB;
use esmith::Backup;
#use esmith::lockfile;
# lock file.. see bug 9127
my $backup_lock;
$ENV{PATH} = "/sbin/e-smith:/sbin:/bin:/usr/bin";
my $conf = esmith::ConfigDB->open || die("Could not open config db\n");
# set lock.. if not, exit
unless (SetLock()) {
die "Error: failed to create lock file.. is a backup already running?";
}
my $backup = $conf->get('backupwk');
my $status = $backup->prop('status') || 'disabled';
my $program = $backup->prop('Program') || 'dar';
unless ($status eq 'enabled')
{
print "Backup is disabled\n";
exit 0;
}
my $backups = esmith::BackupHistoryDB->open
|| die("Could not open backup history db\n");
my $now = time();
die "backup not allowed twice at the same date/time, delayed to next day\n" if $backups->get($now);
my $backup_rec = $backups->new_record($now, { type => 'backup_record' });
$backup_rec->set_prop('StartEpochTime', "$now");
$backup_rec->set_prop('BackupType', "workstation");
if ($status = system(qw(signal-event pre-backup)))
{
exit bad_exit($backup_rec, "pre-backup", $status);
}
if ($status = system("/etc/e-smith/events/actions/workstation-backup-$program", "DailyBackup"))
{
exit bad_exit($backup_rec, "backup", $status);
}
if ($status = system(qw(signal-event post-backup)))
{
exit bad_exit($backup_rec, "post-backup", $status);
}
$now = time();
$backup_rec->set_prop('EndEpochTime', "$now");
$backup_rec->set_prop('Result', "$status");
# remove lock
RemoveLock();
exit 0;
sub bad_exit
{
my ($backup_rec, $phase, $status) = @_;
my $now = time();
warn("Backup terminated: $phase failed - status: $status\n");
$backup_rec->set_prop('EndEpochTime', "$now");
$backup_rec->set_prop('Result', "$phase:$status");
# remove lock
RemoveLock();
return $status / 256;
}
# subs to set and remove lock on backup
sub SetLock
{
$backup_lock = esmith::Backup::set_lock;
return $backup_lock;
}
sub RemoveLock
{
if (defined($backup_lock))
{
esmith::Backup::remove_lock($backup_lock);
$backup_lock = undef;
}
}

View File

@ -0,0 +1,37 @@
#----------------------------------------------------------------------
# Copyright 1999-2003 Mitel Networks Corporation
# This program is free software; you can redistribute it and/or
# modify it under the same terms as Perl itself.
#----------------------------------------------------------------------
#
#, fuzzy
msgid ""
msgstr ""
"Project-Id-Version: PACKAGE VERSION\n"
"POT-Creation-Date: 2003-03-06 14:53-0500\n"
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
"Language-Team: LANGUAGE <LL@li.org>\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=CHARSET\n"
"Content-Transfer-Encoding: 8bit\n"
#: root/etc/e-smith/templates/etc/cron.d/backup:40
msgid "Remember to load the backup tape!"
msgstr ""
#: root/etc/e-smith/templates/etc/cron.d/backup:47
msgid "Backup task is disabled"
msgstr ""
#: root/etc/e-smith/templates/sbin/e-smith/backup/05check-enabled:7
msgid "Tape backups are enabled"
msgstr ""
#: root/etc/e-smith/templates/sbin/e-smith/backup/05check-enabled:12
msgid "Tape backups have been disabled"
msgstr ""
#: root/etc/e-smith/templates/sbin/e-smith/backup/20probe-tape:22
msgid "Backup aborted: No tape loaded"
msgstr ""

View File

@ -0,0 +1,574 @@
#----------------------------------------------------------------------
# Copyright 1999-2007 Mitel Networks Corporation
# This program is free software; you can redistribute it and/or
# modify it under the same terms as Perl itself.
#----------------------------------------------------------------------
package esmith::Backup;
use strict;
use warnings;
use File::Copy;
use Unix::PasswdFile;
use Passwd::Unix;
use esmith::lockfile;
use vars qw($VERSION @ISA @EXPORT_OK);
use constant ESMITH_RESTORE_CACHE => '/var/cache/e-smith/restore';
use constant ESMITH_BACKUP_LOCK_FILE => "/var/lock/subsys/backup-running";
@ISA = qw(Exporter);
#path to *.include/*.exclude files
my $BackupDir = '/etc/backup-data.d/';
=head1 NAME
esmith::Backup - interface to server backup/restore information
=head1 SYNOPSIS
# When you want to add or remove files/folders
# in your backup, make files in /etc/backup-data.d
# with one or several path name inside (one per line)
# eg : /opt/myContrib
# /usr/share/myContrib
#
# FileName.include -> add more files/folders
# FileName.exclude -> remove files/folder
use esmith::Backup;
my $backup = new esmith::Backup;
#retrieve the list of your backup exclusions
my @backup_excludes = $backup->excludes;
#or
my @backup_excludes = esmith::Backup->excludes;
# retrieve the list of your backup inclusions
my @backup_list = $backup->restore_list;
#or
my @backup_list = esmith::Backup->restore_list;
=head1 DESCRIPTION
This module provides an abstracted interface to the backup/restore
information
=cut
=begin testing
use esmith::TestUtils qw(scratch_copy);
use_ok("esmith::Backup");
$backup = new esmith::Backup;
isa_ok($backup, 'esmith::Backup');
=end testing
=head2 new
This is the class constructor.
=cut
sub new
{
my $class = ref($_[0]) || $_[0];
my $self = {};
$self = bless $self, $class;
return $self;
}
=head2 restore_list
Returns an (ordered) array of files/directories to recover from the
backup. The pathnames are relative to root.
=cut
sub restore_list
{
my ($self) = @_;
my @backup = (
'home/e-smith',
'etc/e-smith/templates-custom',
'etc/e-smith/templates-user-custom',
'etc/ssh',
'root',
'etc/sudoers',
'etc/passwd',
'etc/shadow',
'etc/group',
'etc/gshadow',
'etc/samba/secrets.tdb',
'etc/samba/smbpasswd',
'etc/samba/schannel_store.tdb',
'etc/backup-data.d',
'var/lib/samba/group_mapping.tdb',
'var/lib/samba/account_policy.tdb',
);
#add all paths in .include files
push @backup, $self->includes;
return @backup;
}
=head2 uniq
Remove all duplicates from the given array.
=cut
sub uniq {
return keys %{{ map { $_ => 1 } @_ }};
}
=head2 load_file_list
head2 load_file_list
Given a file name, return all lines in an array.
=cut
sub load_file_list
{
my ($self, $file) = @_;
my @paths;
open (FILE, $file) or die 'Unable to open the list file: $file';
while (<FILE>) {
#sanitise the line
s/^\s+|\s+$//g;
s/^\/+|\/+$|\n+//g;
s/\/+/\//g;
#we don't want blank line or space
next if /^$|\s+/;
# we don't want some characters
next if /`|'|"|;|&|\||#|\\|:|\*|<|>/;
push(@paths, $_);
}
close(FILE);
return @paths;
}
=head2 load_files_from_dir
Given a directory and an extension, return all lines
from all files using load_file_list function.
=cut
sub load_files_from_dir
{
my ($self, $dir, $extension ) = @_;
my @ret;
my @files = <$dir*.$extension>;
foreach my $file (@files) {
push(@ret,$self->load_file_list($file));
}
return @ret;
}
=head2 includes
Takes a directory as argument.
Returns a list of files from all .include files inside the given directory.
All duplicates are removed.
=cut
sub includes
{
my ($self) = @_;
return uniq($self->load_files_from_dir($BackupDir,'include'));
}
=head2 excludes
Takes a directory as argument.
Returns a list of files from all .exclude files inside the given directory.
All duplicates are removed.
=cut
sub excludes
{
my ($self) = @_;
return uniq($self->load_files_from_dir($BackupDir,'exclude'));
}
=head2 merge_passwd
Merge password files. Takes a filename of a restored password
file and an optional filename for the final merged password file,
defaulting to /etc/passwd
=item *
Save away the recently restored passwd file
=item *
Put the pre-restore passwd file back in place
=item *
Add back any users in the restored passwd file with home
directories under directories which contain user or
machine accounts
=item *
Log any other missing users or UID/GID mismatches
=begin testing
my $installed = '10e-smith-backup/passwd-installed';
my $restored = scratch_copy('10e-smith-backup/passwd-restored');
is($backup->merge_passwd($installed, $restored), 1, 'merge_passwd worked');
use Digest::MD5;
open(FILE, '10e-smith-backup/passwd-merged') || die $!;
my $srcmd5 = Digest::MD5->new->addfile(*FILE)->hexdigest;
open(FILE, $restored) || die $1;
my $destmd5 = Digest::MD5->new->addfile(*FILE)->hexdigest;
close FILE;
is( $srcmd5, $destmd5, 'merge_passwd output looks good' );
=end testing
=cut
my @Scratch_Files = ();
END { unlink @Scratch_Files }
sub merge_passwd
{
my ($self, $pre_restored, $restored) = @_;
$restored ||= '/etc/passwd';
my $tmp = "${restored}.$$";
push @Scratch_Files, $tmp;
copy $restored, $tmp or warn "Couldn't copy $restored, $tmp\n";
copy $pre_restored, $restored or warn "Couldn't copy $pre_restored, $restored\n";
my $merge_from = new Unix::PasswdFile($tmp, rmode => 'r' );
unless ($merge_from)
{
warn "merge_passwd: Couldn't open restored password object\n";
return undef;
}
my $merge_into = new Unix::PasswdFile($restored);
unless ($merge_into)
{
warn "merge_passwd: Couldn't open current password object\n";
return undef;
}
foreach my $user ($merge_from->users)
{
my @details = $merge_into->user($user);
if ( _homedir_ok($merge_from->home($user)) )
{
unless ( defined $details[0] )
{
$merge_into->user($user, $merge_from->user($user));
warn "merge_passwd: Restoring user $user\n";
}
next;
}
unless ( defined $details[0] )
{
warn "merge_passwd: $user - Missing after restore\n";
next;
}
unless ( $merge_into->uid($user) eq $merge_from->uid($user) )
{
warn "merge_passwd: $user - UID changed during restore\n";
next;
}
unless ( $merge_into->gid($user) eq $merge_from->gid($user) )
{
warn "merge_passwd: $user - GID changed during restore\n";
next;
}
}
$merge_into->commit;
return 1;
}
=head2 merge_group
Merge group files. Takes a filename of a restored group
file and an optional filename for the final merged group file,
defaulting to /etc/group.
=item *
Save away the recently restored group file
=item *
Put the pre-restore group file back in place
=item *
Add back any group in the restored group file for which
there are corresponding users with valid home directories.
These users are checked from the passwd file specified in the environment
variable ESMITH_BACKUP_PASSWD_FILE, or /etc/passwd.
=item *
Log any other missing groups or GID mismatches
=item *
Adjust www, admin, shared groups
=begin testing
my $installed = '10e-smith-backup/group-installed';
my $restored = scratch_copy('10e-smith-backup/group-restored');
$ENV{ESMITH_BACKUP_PASSWD_FILE} = '10e-smith-backup/passwd-merged';
is($backup->merge_group($installed, $restored), 1, 'merge_group worked');
use Digest::MD5;
open(FILE, '10e-smith-backup/group-merged') || die $!;
my $srcmd5 = Digest::MD5->new->addfile(*FILE)->hexdigest;
open(FILE, $restored) || die $1;
my $destmd5 = Digest::MD5->new->addfile(*FILE)->hexdigest;
close FILE;
is( $srcmd5, $destmd5, 'merge_group output looks good' );
=end testing
=cut
sub merge_group
{
my ($self, $pre_restored, $restored) = @_;
$restored ||= '/etc/group';
my $tmp = "${restored}.$$";
push @Scratch_Files, $tmp;
copy $restored, $tmp or warn "Couldn't copy $restored, $tmp\n";
copy $pre_restored, $restored or warn "Couldn't copy $pre_restored, $restored\n";
my $merge_from = new Passwd::Unix(group => $tmp);
unless ($merge_from)
{
warn "merge_group: Couldn't open restored group object\n";
return undef;
}
my $merge_into = new Passwd::Unix(group => $restored);
unless ($merge_into)
{
warn "merge_group: Couldn't open current group object\n";
return undef;
}
my $passwd_file = $ENV{ESMITH_BACKUP_PASSWD_FILE} || '/etc/passwd';
my $passwd = new Unix::PasswdFile($passwd_file, rmode => 'r' );
unless ($passwd)
{
warn "merge_group: Couldn't open password object\n";
return undef;
}
foreach my $group ($merge_from->groups)
{
my @details = $merge_into->group($group);
if ( $passwd->user($group) and _homedir_ok($passwd->home($group)) )
{
unless ( defined $details[0] )
{
$merge_into->group($group, $merge_from->group($group));
warn "merge_group: Restoring group $group\n";
}
next;
}
unless ( defined $details[0] )
{
warn "merge_group: $group - Missing after restore\n";
next;
}
my ($merge_into_gid, undef) = $merge_into->group($group);
my ($merge_from_gid, undef) = $merge_from->group($group);
unless ($merge_into_gid eq $merge_from_gid)
{
warn "merge_group: $group - GID changed during restore\n";
next;
}
}
foreach my $special_group ( qw(admin www shared) )
{
$merge_into->group($special_group, $merge_from->group($special_group));
}
return 1;
}
=head2 save_system_files
Save away system files which get cobbered by a restore
=cut
sub save_system_files
{
my ($self) = @_;
my $return = 1;
unless (chdir ESMITH_RESTORE_CACHE)
{
warn "Couldn't change to cache directory\n";
return undef;
}
foreach my $file ( $self->restore_list )
{
if ( -f "/$file" )
{
unless (copy "/$file", "./$file")
{
warn "Couldn't copy /$file to ./$file\n";
$return = undef;
}
}
}
return $return;
}
=head2 merge_system_files
Merge restored system files with ones on the system
=cut
sub merge_system_files
{
my ($self) = @_;
unless (chdir ESMITH_RESTORE_CACHE)
{
warn "Couldn't change to cache directory\n";
return undef;
}
if ( -f "./etc/passwd" and -f "/etc/passwd" )
{
$self->merge_passwd( "./etc/passwd", "/etc/passwd" );
}
else
{
warn "Skipping password file merge\n";
}
if ( -f "./etc/group" and -f "/etc/group" )
{
$self->merge_group( "./etc/group", "/etc/group" );
}
else
{
warn "Skipping group file merge\n";
}
my $now = time();
foreach my $file ( $self->restore_list )
{
if ( -f "./$file" )
{
warn "Preserving $file as $file.$now\n";
rename "./$file", "./$file.$now"
or warn "Couldn't rename ./$file, ./$file.$now\n";
}
}
return 1;
}
=head2 _homedir_ok
Returns true if the given directory is one we want to
restore: /home/e-smith for user accounts or
/noexistingpath for machine accounts
=cut
sub _homedir_ok
{
my $dir = shift or return;
return $dir =~ m:^/(home/e-smith|noexistingpath): ;
}
=head2
set_lock - set lock before running backup
see bug #9217
=cut
sub set_lock
{
return esmith::lockfile::LockFileOrReturn(ESMITH_BACKUP_LOCK_FILE);
}
=head2
remove_lock - remove lock after running backup
=cut
sub remove_lock
{
esmith::lockfile::UnlockFile(shift);
}
=head1 AUTHOR
SME Server Developers <bugs@e-smith.com>
=head1 SEE ALSO
=cut
1;

View File

@ -0,0 +1,94 @@
#----------------------------------------------------------------------
# Copyright 1999-2003 Mitel Networks Corporation
# This program is free software; you can redistribute it and/or
# modify it under the same terms as Perl itself.
#----------------------------------------------------------------------
package esmith::BackupHistoryDB;
use strict;
use warnings;
use esmith::DB::db;
our @ISA = qw( esmith::DB::db );
=head1 NAME
esmith::BackupHistoryDB - interface to esmith backup history database
=head1 SYNOPSIS
use esmith::BackupHistoryDB;
my $c = esmith::BackupHistoryDB->open;
# everything else works just like esmith::DB::db
=head1 DESCRIPTION
This module provides an abstracted interface to the esmith master
configuration database.
Unless otherwise noted, esmith::BackupHistoryDB acts like esmith::DB::db.
=cut
=head2 open()
Like esmith::DB->open, but if given no $file it will try to open the
file in the ESMITH_BACKUPHISTORY_DB environment variable or "backups" in
the default database directory.
=begin testing
use_ok("esmith::BackupHistoryDB");
$C = esmith::BackupHistoryDB->open('10e-smith-backup/backuphistory.conf');
isa_ok($C, 'esmith::BackupHistoryDB');
my $rec = $C->get('1053551285');
isa_ok($rec, 'esmith::DB::Record');
is( $rec->prop('EndEpochTime'), 1053551299,
"We can get stuff from the db");
=end testing
=cut
sub open {
my($class, $file) = @_;
$file = $file || $ENV{ESMITH_BACKUPHISTORY_DB} || "backups";
return $class->SUPER::open($file) || $class->SUPER::create($file);
}
=head2 open_ro()
Like esmith::DB->open_ro, but if given no $file it will try to open the
file in the ESMITH_BACKUPHISTORY_DB environment variable or "backups" in
the default database directory.
=begin testing
=end testing
=cut
sub open_ro {
my($class, $file) = @_;
$file = $file || $ENV{ESMITH_BACKUPHISTORY_DB} || "backups";
return $class->SUPER::open_ro($file);
}
=head1 AUTHOR
SME Server Developers <bugs@e-smith.com>
=head1 SEE ALSO
L<esmith::DB::db>
L<esmith::DB::Record>
=cut
1;

View File

@ -0,0 +1,510 @@
#----------------------------------------------------------------------
# Copyright 2015 Ian Wells
# This program is free software; you can redistribute it and/or
# modify it under the same terms as Perl itself.
#----------------------------------------------------------------------
package esmith::BlockDevices;
use strict;
use warnings;
use English '-no_match_vars';
use Carp;
use File::Path qw(make_path remove_tree);
use POSIX qw(:sys_wait_h strftime);
use Locale::gettext;
use File::stat;
use v5.10.1;
use Taint::Util;
use Readonly;
use File::Find;
use vars qw($VERSION @ISA @EXPORT_OK);
@ISA = qw(Exporter);
=head1 NAME
esmith::BlockDevices - Module to handle block devices
=head1 SYNOPSIS
use esmith::BlockDevices;
my $devices = BlockDevices->new ();
=head1 DESCRIPTION
This module provides an abstracted interface to the
block devices used for backup/restore
=cut
my $EMPTY = q{};
sub new
{
my $class = shift;
my $self = {
_blox => lsblk(),
mount => findValidFS(),
_fstype => $EMPTY,
allowmount => $EMPTY,
@_,
};
bless $self, $class;
return $self;
}
sub lsblk
{
#ToDo add some comments
my %blox; # a hash to hold the device information
my $short = qx(/bin/lsblk -sdn -o KNAME);
my @long = qx(/bin/lsblk -P -b -o KNAME,MAJ:MIN,RM,RO,TYPE,MOUNTPOINT,FSTYPE,LABEL,UUID,MODEL,SIZE,STATE,MODE,OWNER,GROUP);
# Not all of this information may be needed currently, but it does not affect the processing time
untaint ($short);
untaint (@long);
my $devicemodel= $EMPTY;
for (@long)
{
my @line = split /\"\s/s;
my $name;
if ($line[0] =~ /KNAME=\"(.*)/s)
{
$name = $1;
}
else {carp 'Could not match KNAME'; last;} # should never occur.
$blox{$name}{tip} = ($short =~ m/^$name$/sm) ? 1 : 0;
for (@line)
{
my ($key,$value) = split /=/s;
$value =~ s/\"//sg;
$blox{$name}{$key} = trim($value);
}
if ($blox{$name}{TYPE} =~ /rom|disk/s)
{
$devicemodel = $blox{$name}{MODEL};
}
else
{
$blox{$name}{MODEL} = trim($devicemodel);
}
$blox{$name}{SIZEH} = scaleIt($blox{$name}{SIZE});
}
return \%blox;
}
sub findValidFS
{
# Find all filesystem types that are supported
my %fs; # a hash to hold the supported filesystem type information
my @cmd = `cat /proc/filesystems`;
foreach (@cmd)
{
if (/.*\t(.*?)$/s){$fs {$1}=$1;}
}
@cmd = `ls -1 /lib/modules/\$(uname -r)/kernel/fs/*/*ko.*`;
foreach (@cmd)
{
if (/.*\/(.*?)\.ko/s){$fs {$1}=$1;}
}
# If ext4 driver is present, add ext2 and ext3
if(exists($fs{ext4}))
{
$fs{'ext2'}='ext2';
$fs{'ext3'}='ext3';
}
return \%fs;
}
sub scanBlocks
{
# Scan all the block devices
# This takes some seconds on systems with many filesystems
my ($self) = @_;
$self->{_blox} = lsblk;
$self->{_fstype} = findValidFS;
return;
}
sub list
{
my ($self) = @_;
my @dirs=();
my $hashref = $self->{_blox};
foreach my $drive (keys %{$hashref})
{
push @dirs, $drive;
}
return @dirs;
}
sub checkBackupDriveSize
{
my ($self,$drive, $size) = @_;
my $hashref = $self->{_blox};
my $sz = $EMPTY;
my $mntdir = $self->{mount};
Readonly my $VFAT_LIMIT => 2147483648;
Readonly my $KBYTE => 1024;
# size > drive size
if ($size > $hashref->{$drive}{SIZE})
{
return 1; # filesystem too small
}
# FAT32 drive and size > 2G
if (($size > $VFAT_LIMIT) && ($hashref->{$drive}{FSTYPE} eq 'vfat'))
{
return 2; # filesystem vfat limit
}
#ToDo add a check here to see if mounting is allowed by db value
# check mount and find actual size
if ($self->mountable ($drive)) # Only check filesystems that appear mountable
{
$self->mount ($drive);
my $filesize = -s "$mntdir/smeserver.tgz";
# Check free disk space
my $df = qx(/usr/bin/df -P \"$mntdir\");
if ($df =~ /(\S+)\s+(\S+)\s+(\S+)\s+(\d*%)/s)
{
my $dsize = ($3 * $KBYTE) + ($filesize //= 0);
if ($size > $dsize) # not enough space
{
$sz = 3; # filesystem has too little free space
}
}
else # fail (never seen in testing)
{
$sz = 4; # Failed to get disk size
}
$self->unmount;
}
return $sz;
}
# Check each block device
# Return two arrays, valid drives, invalid drives
sub checkBackupDrives
{
my ($self,$bsize) = @_;
my @valid = ();
my @invalid = ();
$self->scanBlocks; # scan all block devices
my $hashref = $self->{_blox};
my $allowmount = $self->{'allowmount'}; # Are mounted drives allowed in $checks.
my $checks = 'UU RO FS'; # These checks are always valid
$checks .= ' MO' if ($allowmount eq 'enabled');
$checks .= ' SZ' if ($bsize); # Only run the size check when a valid size is given
foreach my $drive (keys %{$hashref})
{
$hashref->{$drive}{REASON} = $EMPTY; # Reason for a filesystem being (in)valid
next unless $hashref->{$drive}{tip}; #Ignore drives that have child filesystems
# drives mounted on /, /boot, or [SWAP] are never valid for backups
next if ($hashref->{$drive}{MOUNTPOINT} =~ /^\/boot$|^\[SWAP\]$|^\/$/s );
# validate each filesystem against the checks
foreach my $check (split / /s, $checks)
{
for ($check)
{
if (/^UU/si) # No UUID
{
$hashref->{$drive}{REASON} .='UU ' unless $self->uuid ($drive); last;
}
if (/^RO/si) # Read Only
{
$hashref->{$drive}{REASON} .='RO ' if $self->readonly ($drive); last;
}
if (/^FS/si) # Invalid filesystem
{
$hashref->{$drive}{REASON} .='FS ' unless $self->validFS ($drive); last;
}
if (/^MO/si) # Mounted
{
$hashref->{$drive}{REASON} .='MO ' if $self->mountpoint ($drive); last;
}
if (/^SZ/si) # filesystem size, this includes mounting to check free space
{
$hashref->{$drive}{REASON} .='SZ ' if $self->checkBackupDriveSize ($drive, $bsize);
#ToDo the return value contains the reason why there is insufficient space, but this is not used yet.
last;
}
{ carp "not supported yet in checkBackupDrives: $check"; } # Should never be seen
}
}
if ($hashref->{$drive}{REASON})
{
push @invalid, $drive;
}
else
{
push @valid, $drive;
}
}
return (\@valid, \@invalid);
}
sub findBackup
{
my ($self, $kname, $foundref, $maxDepth, $count) = @_;
my $hashref = $self->{_blox};
my $mountpoint = $self->{'mount'};
my $file = 'smeserver.tgz';
$self->mount ($kname);
sleep 1;
# start with the absolute path
my $findRoot = Cwd::realpath($mountpoint);
# determine the depth of our beginning directory
my $begDepth = 1 + grep { length } File::Spec->splitdir($findRoot);
find (
{
preprocess => sub
{ @_ if (scalar File::Spec->splitdir($File::Find::dir) - $begDepth) <= $maxDepth },
wanted => sub
{
if (($_ =~ m/^$file/s) && ($File::Find::name =~ qr|^([-+@\w\s./:\\]+)$| )) # if matching the backup name
{
$$count++;
my $sb = stat $1;
${$foundref}{$$count}{count}=$$count;
${$foundref}{$$count}{device}=$kname;
${$foundref}{$$count}{path} = $1;
${$foundref}{$$count}{path} =~ s/$mountpoint//; #strip off the mountpoint
${$foundref}{$$count}{path} =~ s/$file//; #strip off the filename
${$foundref}{$$count}{size}=$sb->size; # size in bytes
${$foundref}{$$count}{sizeH}=scaleIt($sb->size); # human readable size
${$foundref}{$$count}{time}=strftime '%d %b %g %H:%M', localtime $sb->mtime;
}
},
untaint => 1,
untaint_pattern => qr|^([-+@\w\s./:\\]+)$|,
untaint_skip =>1,
},
$findRoot
);
$self->unmount;
return;
}
sub desc # brief description of a filesystem
{
my ($self,$kname) = @_;
my $hashref = $self->{_blox};
my $model = $hashref->{$kname}{MODEL};
my $label = $hashref->{$kname}{LABEL} || gettext('no label');
my $size = $hashref->{$kname}{SIZEH};
return "$label $model $size";
}
# Given the KNAME check if the filesystem.could be mountable
# Check that there are no children, i.e. a tip
# Check that it has a UUID, Filesystem,
sub mountable
{
my ($self,$kname) = @_;
my $hashref = $self->{_blox};
return ($hashref->{$kname}{tip} && $hashref->{$kname}{UUID} && _isFS ($hashref->{$kname}{FSTYPE})) ? 1 : $EMPTY;
}
# Given the KNAME check if the filesystem.is read-only
# returns 1 for Read-Only and $EMPTY for R-W
sub readonly
{
my ($self,$kname) = @_;
my $hashref = $self->{_blox};
return ($hashref->{$kname}{RO}) ? 1 : $EMPTY;
}
sub mountpoint
{
my ($self,$kname) = @_;
my $hashref = $self->{_blox};
return ($hashref->{$kname}{MOUNTPOINT});
}
sub uuid
{
my ($self,$kname) = @_;
my $hashref = $self->{_blox};
return ($hashref->{$kname}{UUID});
}
sub model
{
my ($self,$kname) = @_;
my $hashref = $self->{_blox};
return ($hashref->{$kname}{MODEL});
}
# Given the KNAME return the label
# returns 'no label' if none found
sub label
{
my ($self,$kname) = @_;
my $hashref = $self->{_blox};
return ($hashref->{$kname}{LABEL}) || gettext('no label');
}
sub size
{
my ($self,$kname) = @_;
my $hashref = $self->{_blox};
return ($hashref->{$kname}{SIZE});
}
# Given a filesystem.(eg sr0) check if it's filesystem type is allowed
sub validFS
{
my ($self,$kname) = @_;
my $hashref = $self->{_blox};
my $fsref = $self->{_fstype};
return ($fsref->{$hashref->{$kname}{FSTYPE}}) || $EMPTY;
}
# Given a filesystem.type (eg vfat) check if it is allowed
sub _isFS
{
my ($filesystem) = @_;
return $EMPTY unless $filesystem;
my $fsref = findValidFS;
return ($fsref->{$filesystem}) || $EMPTY;
}
# Return the reason string which indicates why a drive is (in)valid
sub reason
{
my ($self,$kname) = @_;
my $hashref = $self->{_blox};
return ($hashref->{$kname}{REASON});
}
# Given the KNAME mount the filesystem, example
# system ('/bin/mount', '-t', 'vfat', '-U', '9891-4C8A', '/tmp/mnt');
sub mount
{
my ($self, $kname) = @_;
my $hashref = $self->{_blox};
$self->createMountpoint;
system ('/bin/mount', '-t', $hashref->{$kname}{FSTYPE}, '-U', $hashref->{$kname}{UUID}, $self->{mount}) == 0
or croak (gettext('Failed to mount')." $self->{mount},$hashref->{$kname}{FSTYPE},$hashref->{$kname}{UUID}: $?");
return;
}
# Unmount the block device
sub unmount
{
my $self = shift;
system('/bin/umount', $self->{mount}) == 0
or croak (gettext('Failed to unmount')." $self->{mount}: $?");
return;
}
# Create the mountpoint directory
# Error if already mounted
sub createMountpoint
{
my $self = shift;
my $mount = $self->{mount};
# Check if the mountpoint is in use
if (!checkMount ($mount))
{
# Try to unmount, will die if fails
$self->unmount;
}
if ($mount && ! -d $mount)
{
eval {make_path($mount)};
croak (gettext('Error while creating')." $mount $EVAL_ERROR".gettext('Maybe insufficient permissions.')) if $EVAL_ERROR;
}
return;
}
sub destroy
{
# cleanup, unmount and remove mountpoint
my $self = shift;
my $mount = $self->{mount};
# Check if the mountpoint is in use
if (!checkMount ($mount))
{
$self->unmount;
}
if ($mount && -d $mount)
{
eval {remove_tree($mount)};
croak (gettext('Error while deleting')." $mount $EVAL_ERROR") if $EVAL_ERROR;
}
return;
}
### The following subroutines are not specific to block devices
sub scaleIt {
Readonly my $KBYTE => 1024;
my( $size, $n ) =( shift, 0 );
++$n and $size /= $KBYTE until $size < $KBYTE;
if ($size >= 1000){++$n ; $size /= $KBYTE;}
return sprintf "%.3g %s",
$size, ( qw[ bytes KB MB GB TB] )[ $n ];
}
sub checkMount
{
# check if $mountdir is mounted
my $mountdir = shift;
$|=1; # Auto-flush
# copy STDOUT to another filehandle
open (my $STDOLD, '>&', STDOUT);
open(STDOUT, ">/dev/null");
if ( open(MOUNTDIR, "|-", "/bin/findmnt", $mountdir)){;}
# restore STDOUT
open (STDOUT, '>&', $STDOLD);
return (!close(MOUNTDIR));
}
# remove leading and trailing spaces from a string
# this should be moved to a util library.
sub trim
{
my ($string) = @_;
$string =~ s/^\s+|\s+$//g;
return $string;
}
1;

View File

@ -0,0 +1,61 @@
package esmith::console::backup_running;
use strict;
use warnings;
use esmith::ConfigDB;
use Locale::gettext;
sub new
{
my $class = shift;
my $self = {};
bless $self, $class;
return $self;
}
sub doit
{
my ($self, $console, $db) = @_;
#-------------------------------------------------------------
# check whether a backup in process and incomplete
#-------------------------------------------------------------
my $restore_db = esmith::ConfigDB->open_ro("/etc/e-smith/restore");
return unless $restore_db;
my $restore_state = $restore_db->get_prop('restore', 'state') || 'idle';
return unless ($restore_state eq 'running');
my ($rc, $choice) = $console->message_page
(
title => gettext("Inconsistent system state"),
text =>
gettext("********** Inconsistent system state detected ***********") .
"\n\n" .
gettext("The restoration of a system backup was running and incomplete at the time of the last reboot. The system should not be used in this state.") .
"\n\n" .
gettext("Consult the User Guide for further instructions."),
);
($rc, $choice) = $console->yesno_page
(
title => gettext("System will be halted"),
text =>
gettext("The server will now be halted.") .
"\n\n" .
gettext("Consult the User Guide for recovery instructions.") .
"\n\n" .
gettext("Do you wish to halt the system right now?"),
);
return unless ($rc == 0);
system("/usr/bin/tput", "clear");
system("/sbin/e-smith/signal-event", "halt");
# A bit of a hack to avoid the console restarting before the
# reboot takes effect.
sleep(600);
}
1;

View File

@ -0,0 +1,294 @@
package esmith::console::perform_backup;
use strict;
use warnings;
use esmith::ConfigDB;
use esmith::console;
use esmith::util;
use Locale::gettext;
use esmith::Backup;
use Carp;
use feature qw( say );
use esmith::BlockDevices;
use POSIX qw(:sys_wait_h strftime);
use File::stat;
use Taint::Util;
my $EMPTY = q{};
# lock file.. see bug 9127
my $backup_lock;
sub new
{
my $class = shift;
my $self = {
name => gettext("Perform backup to removable media"),
order => 80,
};
bless $self, $class;
return $self;
}
sub name
{
return $_[0]->{name};
}
sub order
{
return $_[0]->{order};
}
sub backup_size
{
my $self = shift;
}
# subs to set and remove lock on backup
sub SetLock
{
print "Setting backup lock file\n";
$backup_lock = esmith::Backup::set_lock;
return $backup_lock;
}
sub RemoveLock
{
if (defined($backup_lock))
{
print "Removing backup lock file\n";
esmith::Backup::remove_lock($backup_lock);
$backup_lock = undef;
}
}
sub make_backup_callback
{
my ($device, $CompressionLevel) = @_;
return sub {
my $fh = shift;
my @backup_list = esmith::Backup->restore_list;
my @backup_excludes = esmith::Backup->excludes;
my $backup_size = backupSize (@backup_list);
# set lock.. if not, exit
unless (SetLock()) {
die "Error: failed to create lock file.. is a backup already running?";
}
open(OLDSTDOUT, ">&STDOUT");
unless (open(STDOUT, ">$device/smeserver.tgz"))
{
return gettext("Could not create backup file on device").": $!\n";
}
open(OLDSTDERR, ">&STDERR");
my $logger = open(STDERR, "|-");
die "Can't fork: $!\n" unless defined $logger;
unless ($logger)
{
exec qw(/usr/bin/logger -p local1.info -t console_backup);
}
my $status = 0;
my $gzip = open(GZIP, "|-");
return "could not run gzip" unless defined $gzip;
unless ($gzip)
{
close $fh;
exec "gzip", $CompressionLevel;
}
my $pv = open(PV, "|-");
return "could not run pv" unless defined $pv;
unless ($pv)
{
open(STDOUT, ">&GZIP");
close GZIP;
open(STDERR, ">&$fh");
exec qw(pv -i 0.2 -n -s), $backup_size
}
my $tar = fork;
return "could not run tar" unless defined $tar;
unless ($tar)
{
open(STDOUT, ">&PV");
close PV;
close GZIP;
close $fh;
chdir "/";
#Create the archive
my @directories = grep { -e $_ } @backup_list;
my @exclude = map ("--exclude=$_",@backup_excludes);
exec ("/bin/tar cf - @directories @exclude");
}
waitpid($tar, 0);
warn "status from tar was $?\n" if $?;
unless (close PV)
{
$status |= $! ? $! : $?;
warn "status from pv is $status\n" if $status;
}
unless (close GZIP)
{
$status |= $! ? $! : $?;
warn "status from gzip is $status\n" if $status;
}
open(STDOUT, ">&OLDSTDOUT");
open(STDERR, ">&OLDSTDERR");
close(OLDSTDERR);
close(OLDSTDOUT);
RemoveLock();
return $status ? gettext("Backup failed. Look at the log files for more details.") : gettext("Backup successfully created.");
};
}
sub doit
{
my ($self, $console, $db) = @_;
my @backup_list = esmith::Backup->restore_list;
my @backup_excludes = esmith::Backup->excludes;
my $compressionLevel = $db->get_prop('backupconsole', 'CompressionLevel') || '-6';
my $mountpoint = $db->get_prop('backupconsole', 'Mountpoint') || '/mnt/bootstrap-console-backup';
my $allowMounted = $db->get_prop('backupconsole', 'AllowMounted') || 'disabled'; ### For future use
$ENV{PATH} = "/bin:/usr/bin";
$ENV{HOME} = "/root";
my $devices = esmith::BlockDevices->new ('mount' => $mountpoint, 'allowmount' => $allowMounted);
INITIATE_BACKUP:
my ($rc, $choice) = $console->yesno_page
(
title => gettext("Create Backup to removable media"),
defaultno => 1,
text => gettext('Do you wish to create a backup on removable media?')."\n\n".
gettext('Insert removable media before proceeding.')."\n".
gettext('It may take many seconds to scan for media.'),
);
if ($rc != 0)
{
$devices->destroy;
return;
}
### determine which filesystems are valid or not for backups
# check expected backup size
my $backup_size = backupSize (@backup_list);
# validate each filesystem
my ($valid, $invalid) = $devices->checkBackupDrives ($backup_size);
my $text = $EMPTY;
if (${$invalid}[0]) # If there are filesystems that are not valid.
{
$text .= gettext ('These filesystems are not valid:')."\n";
foreach my $drive (sort @{$invalid})
{
$text .= "$drive ".$devices->desc($drive).' '.gettext ('Reason').': '.$devices->reason($drive)."\n";
}
$text .= "\n";
}
unless (${$valid}[0]) # Unless a device is found show error page
{
my $title = gettext('No valid backup device found').' '.gettext('size').' '.esmith::BlockDevices::scaleIt($backup_size);
$text .= "\n$title, ".gettext('please try again');
($rc, $choice) = $console->yesno_page
(
title => $title,
text => $text,
left => gettext('Try again'),
right => gettext('Cancel'),
);
if ($rc == 0) # Try Again
{
goto INITIATE_BACKUP;
}
else
{
$devices->destroy;
return;
}
}
$text .= gettext ('The following are valid for backup').' (';
$text .= gettext ('size').' '.esmith::BlockDevices::scaleIt($backup_size).')';
#ToDo when valid + invalid > 13 then may need to limit the information
my @args = map { $_ => $devices->desc($_) } @{$valid};
# Display the available backup destinations.
($rc, $choice) = $console->menu_page
(
title => gettext('Choose device to use for backup').' '.gettext('size').' '.esmith::BlockDevices::scaleIt($backup_size),
text => $text,
argsref => \@args,
left => gettext('Cancel'),
right => gettext('OK'),
);
goto INITIATE_BACKUP unless ($rc == 0);
untaint $choice;
$devices->mount ($choice); # mount the chosen filesystem
if (@backup_excludes) {
my $backupexclude = join ("\n/", sort @backup_excludes);
($rc, $choice) = $console->yesno_page
(
title => gettext("Some parts are excluded of your backup"),
left => gettext("Next"),
right => gettext("Cancel"),
text => '/' . $backupexclude,
);
return unless $rc == 0;
}
$console->infobox(
title => gettext("Preparing for backup"),
text => gettext("Please stand by while the system is prepared for backup..."),
);
system("/sbin/e-smith/signal-event", "pre-backup");
$console->gauge(make_backup_callback($mountpoint,$compressionLevel), 'title' => gettext('Creating backup file'));
$devices->destroy;
system("/sbin/e-smith/signal-event", 'post-backup');
RemoveLock();
$console->message_page
(
title => gettext('Backup complete'),
text => gettext('Remove backup media.'),
);
return;
}
sub backupSize
{
my $size;
unless (open(DU, "-|"))
{
open(STDERR, ">/dev/null");
exec qw(/usr/bin/du -sb), map { "/$_" } @_;
}
while (<DU>)
{
next unless (/^(\d+)/);
$size += $1;
}
close DU;
return $size;
}
#use esmith::console;
#esmith::console::perform_backup->new->doit(esmith::console->new,
# esmith::ConfigDB->open);
1;

View File

@ -0,0 +1,340 @@
package esmith::console::perform_restore;
use strict;
use warnings;
use esmith::ConfigDB;
use esmith::console;
use Locale::gettext;
use Carp;
use feature qw( say );
use esmith::BlockDevices;
use Taint::Util;
use esmith::Backup;
use Data::UUID;
my $EMPTY = q{};
my $backup_lock;
sub new
{
my $class = shift;
my $self = {
name => gettext("Restore from removable media"),
order => installOrder(),
bootstrap => 0,
@_,
};
bless $self, $class;
return $self;
}
sub name
{
return $_[0]->{name};
}
sub order
{
return $_[0]->{order};
}
sub SetLock
{
print "Setting backup lock file\n";
$backup_lock = esmith::Backup::set_lock;
return $backup_lock;
}
sub RemoveLock
{
if (defined($backup_lock))
{
print "Removing backup lock file\n";
esmith::Backup::remove_lock($backup_lock);
$backup_lock = undef;
}
}
sub new_restore_id
{
my $ug = Data::UUID->new;
my $uid = $ug->create_str();
return $uid;
}
sub make_restore_callback
{
my ($mountpoint, $restoreid) = @_;
return sub {
my $fh = shift;
# Check no other backups or restores are in progress
unless (SetLock()) {
die "Error: failed to create lock file. Is a backup or restore already running?";
}
open(OLDSTDOUT, ">&STDOUT");
my $status = 0;
chdir "/";
open(OLDSTDERR, ">&STDERR");
my $logger = open(STDERR, "|-");
die "Can't fork: $!\n" unless defined $logger;
unless ($logger)
{
exec qw(/usr/bin/logger -p local1.info -t console_restore);
}
my $tar = open(TAR, "|-");
return "could not run tar" unless defined $tar;
unless($tar)
{
exec "tar xf -";
}
my $gunzip = open(GUNZIP, "|-");
return "could not run gunzip" unless defined $gunzip;
unless($gunzip)
{
open(STDOUT, ">&TAR");
close TAR;
exec "gunzip";
}
my $pv = fork;
return "could not run pv" unless defined $pv;
unless ($pv)
{
open(STDOUT, ">&GUNZIP");
open(STDERR, ">&$fh");
close GUNZIP;
close TAR;
exec "pv -n $mountpoint/smeserver.tgz";
}
waitpid($pv,0);
warn "status from pv was $?\n" if $?;
unless(close GUNZIP)
{
$status |= $! ? $! : $?;
warn "status from gunzip is $status\n" if $status;
}
unless(close TAR)
{
$status |= $! ? $! : $?;
warn "status from tar is $status\n" if $status;
}
open(STDOUT, ">&OLDSTDOUT");
open(STDERR, ">&OLDSTDERR");
close(OLDSTDOUT);
close(OLDSTDERR);
# Unlock and check for success or failure before returning
RemoveLock();
if ($status) {
return gettext("Restore failed. Your system is likely in an inconsistent state - look at the log files for more details.");
} else {
system("touch", "/tmp/restore_$restoreid");
return gettext("Restore successful.");
}
}
}
sub doit
{
my ($self, $console, $db) = @_;
my $compressionLevel = $db->get_prop('backupconsole', 'CompressionLevel') || '-6';
my $mountpoint = $db->get_prop('backupconsole', 'Mountpoint') || '/mnt/bootstrap-console-backup';
my $allowMounted = $db->get_prop('backupconsole', 'AllowMounted') || 'disabled'; ### For future use
my $restoreMaxDepth = $db->get_prop('backupconsole', 'MaxDepth') || 1; ### For future use
my %found;
my $backupcount = 0;
my $backupdrive; # Which filesystem holds the backup
my $backupfile; # full path to the backup
my ($time, $size); # time and size of chosen backup
return if (($db->get_prop('bootstrap-console', 'Run') eq 'no') && $self->{bootstrap} ); # regular reboot
if ($db->get_prop('bootstrap-console', 'Run') eq 'yes') # called from bootstrap console
{
return if ($db->get_value('PasswordSet') eq 'yes'); # too late
}
return if ($db->get_prop('bootstrap-console', 'Restore') eq 'disabled');
my $devices = esmith::BlockDevices->new ('mount' => $mountpoint, 'allowmount' => $allowMounted);
INITIATE_RESTORE:
my ($rc, $choice) = $console->yesno_page
(
title => gettext("Restore From Backup"),
defaultno => 1,
text => gettext('Do you wish to restore from backup?')."\n\n".
gettext('Insert removable media before proceeding.')."\n".
gettext('It may take many seconds to scan for media.'),
); # Buttons are Yes & No
if ($rc != 0) # choice was not Yes
{
$devices->destroy;
return;
}
### determine which filesystems are valid or not for backups
# validate each filesystem
my ($valid, $invalid) = $devices->checkBackupDrives ($EMPTY);
my $text = $EMPTY;
if (${$valid}[0]) # There are filesystems that could hold a backup.
{
$text .= gettext ('These filesystems could hold backups')."\n";
foreach my $drive (sort @{$valid})
{
$text .= "$drive ".$devices->desc($drive)."\n";
$devices->findBackup ($drive, \%found, $restoreMaxDepth, \$backupcount);
}
$text .= "\n";
}
unless ($backupcount) # Unless a valid backup is found show error page
{
if (${$invalid}[0]) # If there are filesystems that are not valid.
{
$text .= gettext ('These filesystems are not valid:')."\n";
foreach my $drive (sort @{$invalid})
{
$text .= "$drive ".$devices->desc($drive).' '.gettext ('Reason').': '.$devices->reason($drive)."\n";
}
$text .= "\n";
}
my $title = gettext('No valid backup device found');
$text .= "\n$title, ".gettext('please try again');
($rc, $choice) = $console->yesno_page
(
title => $title,
text => $text,
left => gettext('Try again'),
right => gettext('Cancel'),
);
if ($rc == 0) # Try Again
{
goto INITIATE_RESTORE;
}
else
{
$devices->destroy;
return;
}
}
# %found contains $backupcount backups.
if ($backupcount == 1)
{
# One backup found, so simple yes/no choice
$backupdrive = $found{1}{device}; # Find the (only) device that a backup was found on
$backupfile = $found{1}{path}; # find the actual backup
$time = gettext('Date') .' '. $found{1}{time};
$size = gettext('Size') .' '. $found{1}{sizeH};
($rc, $choice) = $console->yesno_page
(
title => gettext('Start restore from backup'),
text =>
gettext('Backup found on device').
"\n$backupdrive ".$devices->desc($backupdrive)."\n\n".
gettext('Backup details').
"\n$backupfile $size $time\n\n\n".
gettext('Do you wish to restore from this file?'),
);
goto INITIATE_RESTORE unless ($rc == 0);
$size = $found{1}{size};
}
else # Multiple backups found so display a choice
{
$text = gettext ('Backups found on these devices')."\n";
foreach my $backupfound (sort keys %found)
{
$backupdrive = $found{$backupfound}{device};
if (($backupfound == 1) || ($found{$backupfound}{device} ne $found{$backupfound-1}{device}))
{
$text.= "$backupdrive ".$devices->desc($backupdrive)."\n";
}
}
my @args = map { $_ => "$found{$_}{device} $found{$_}{path} $found{$_}{sizeH} $found{$_}{time}" } sort keys %found;
($rc, $choice) = $console->menu_page
(
title => gettext('Start restore from backup'),
text =>
"$text\n".
gettext ('Please select the backup that you wish to restore from.'),
argsref => \@args,
left => gettext('Cancel'),
right => gettext('OK'),
);
goto INITIATE_RESTORE unless ($rc == 0);
untaint $choice;
$backupdrive = $found{$choice}{device};
$size = $found{$choice}{size};
}
$devices->mount ($backupdrive); # mount the chosen filesystem
sleep(1); # Some mounts take time to become active
# Prepare for restore
$console->infobox(
title => gettext("Preparing for restore"),
text => gettext("Please stand by while the system is prepared for restore..."),
);
system("/sbin/e-smith/signal-event", "pre-restore");
# Create restore ID to check success later
my $restoreid = new_restore_id();
# Run restore
$console->gauge(make_restore_callback($mountpoint, $restoreid), 'title' => gettext('Restoring from backup'));
# Restore complete, now clean-up. Only post-upgrade and reboot if the restore was successful.
$devices->destroy;
if (-e "/tmp/restore_$restoreid") {
system("/sbin/e-smith/signal-event", "post-upgrade");
$db->set_prop("bootstrap-console", "Run", "yes");
$db->set_prop("bootstrap-console", "ForceSave", "yes");
$db->set_prop("bootstrap-console", "Restore", "disabled");
unless ( $self->{bootstrap} )
{
($rc, $choice) = $console->yesno_page
(
title => gettext("Restore Complete"),
text => gettext('You must restart your system to finish the restore.')."\n\n".
gettext('Do you want to restart now?'),
);
return unless ($rc == 0);
system("/usr/bin/tput", "clear");
system("/sbin/e-smith/signal-event", "reboot");
# A bit of a hack to avoid the console restarting before the
# reboot takes effect.
sleep(600);
}
}
return;
}
# Determine if this server is a fresh install for restore from backup
# Earlier the expression used was ($db->get_value('PasswordSet') eq 'yes')
# To prevent a restore return a negative number
# To allow a restore choose an appropiate sort order, eg 90
sub installOrder
{
my $order = (`grep :x:5...: /etc/group`) ? -1 : 90;
return $order;
}
#use esmith::console;
#esmith::console::perform_restore->new->doit(esmith::console->new,
# esmith::ConfigDB->open);
1;

View File