From fe41ccadec7f1b3797a63a8810c65aecb1ecbf90 Mon Sep 17 00:00:00 2001 From: Brian Read Date: Thu, 26 Oct 2023 11:24:24 +0100 Subject: [PATCH] initial commit of file from CVS for e-smith-backup on Thu 26 Oct 11:24:24 BST 2023 --- .gitignore | 4 + Makefile | 21 + README.md | 18 +- additional/Artistic | 131 + additional/Copying | 340 ++ additional/LICENSE | 33 + contriborbase | 1 + createlinks | 86 + e-smith-backup.spec | 1516 ++++++++ root/etc/backup-data.d/backup.exclude | 2 + root/etc/backup-data.d/backup.include | 2 + root/etc/dar/.gitignore | 0 root/etc/e-smith/db/backups/.gitignore | 0 .../configuration/defaults/backup/BackupType | 1 + .../db/configuration/defaults/backup/Program | 1 + .../configuration/defaults/backup/backupTime | 1 + .../defaults/backup/reminderTime | 1 + .../db/configuration/defaults/backup/status | 1 + .../db/configuration/defaults/backup/type | 1 + .../defaults/backupwk/BackupTime | 1 + .../defaults/backupwk/Compression | 1 + .../defaults/backupwk/CompressionProg | 1 + .../configuration/defaults/backupwk/DaysInSet | 1 + .../defaults/backupwk/IncOnlyTimeout | 1 + .../db/configuration/defaults/backupwk/Login | 1 + .../configuration/defaults/backupwk/Password | 1 + .../configuration/defaults/backupwk/Program | 1 + .../configuration/defaults/backupwk/SetsMax | 1 + .../configuration/defaults/backupwk/SmbHost | 1 + .../configuration/defaults/backupwk/SmbShare | 1 + .../configuration/defaults/backupwk/Timeout | 1 + .../configuration/defaults/backupwk/VFSType | 1 + .../db/configuration/defaults/backupwk/status | 1 + .../db/configuration/defaults/backupwk/type | 1 + .../e-smith/events/actions/delete-index-htm | 2 + root/etc/e-smith/events/actions/eject-tape | 22 + .../e-smith/events/actions/merge-system-files | 31 + .../events/actions/reset-restore-idle-flag | 41 + .../e-smith/events/actions/restore-from-disk | 58 + root/etc/e-smith/events/actions/rewind-tape | 40 + .../e-smith/events/actions/save-system-files | 31 + .../events/actions/workstation-backup-dar | 523 +++ .../etc/e-smith/events/post-backup/.gitignore | 0 root/etc/e-smith/events/pre-backup/.gitignore | 0 .../en-us/etc/e-smith/web/functions/backup | 945 +++++ .../etc/dar/CIFScredentials | 1 + root/etc/e-smith/templates/etc/crontab/backup | 46 + .../e-smith/templates/etc/crontab/backupwk | 30 + .../etc/dar/CIFScredentials/template-begin | 2 + .../etc/dar/DailyBackup.dcf/10compression | 6 + .../etc/dar/DailyBackup.dcf/20empty-dir | 1 + .../etc/dar/DailyBackup.dcf/30fs-root | 1 + .../etc/dar/DailyBackup.dcf/40go-into | 8 + .../templates/etc/dar/DailyBackup.dcf/45prune | 7 + .../etc/dar/DailyBackup.dcf/50exclude | 0 .../dar/DailyBackup.dcf/60exclude-compression | 191 + .../etc/dar/DailyBackup.dcf/70noconf | 1 + .../etc/dar/DailyBackup.dcf/80no-warn | 1 + .../templates/etc/dar/DailyBackup.dcf/90slice | 3 + .../httpd/conf/httpd.conf/97backupProxyEnv | 4 + .../tests/10e-smith-backup/backuphistory.conf | 1 + .../tests/10e-smith-backup/group-installed | 54 + .../tests/10e-smith-backup/group-merged | 58 + .../tests/10e-smith-backup/group-restored | 48 + .../tests/10e-smith-backup/passwd-installed | 46 + .../tests/10e-smith-backup/passwd-merged | 50 + .../tests/10e-smith-backup/passwd-restored | 40 + root/etc/e-smith/web/functions/backup | 3297 +++++++++++++++++ root/mnt/smb/.gitignore | 0 .../e-smith/console-menu-items/usbBackup.pl | 3 + .../e-smith/console-menu-items/usbRestore.pl | 3 + root/sbin/e-smith/do_backup | 113 + root/sbin/e-smith/do_backupwk | 109 + .../share/locale/en_US/LC_MESSAGES/backup.po | 37 + .../share/perl5/vendor_perl/esmith/Backup.pm | 574 +++ .../vendor_perl/esmith/BackupHistoryDB.pm | 94 + .../perl5/vendor_perl/esmith/BlockDevices.pm | 510 +++ .../esmith/console/backup_running.pm | 61 + .../esmith/console/perform_backup.pm | 294 ++ .../esmith/console/perform_restore.pm | 340 ++ .../e-smith/restore/etc/samba/.gitignore | 0 81 files changed, 9900 insertions(+), 2 deletions(-) create mode 100644 .gitignore create mode 100644 Makefile create mode 100644 additional/Artistic create mode 100644 additional/Copying create mode 100644 additional/LICENSE create mode 100644 contriborbase create mode 100644 createlinks create mode 100644 e-smith-backup.spec create mode 100644 root/etc/backup-data.d/backup.exclude create mode 100644 root/etc/backup-data.d/backup.include create mode 100644 root/etc/dar/.gitignore create mode 100644 root/etc/e-smith/db/backups/.gitignore create mode 100644 root/etc/e-smith/db/configuration/defaults/backup/BackupType create mode 100644 root/etc/e-smith/db/configuration/defaults/backup/Program create mode 100644 root/etc/e-smith/db/configuration/defaults/backup/backupTime create mode 100644 root/etc/e-smith/db/configuration/defaults/backup/reminderTime create mode 100644 root/etc/e-smith/db/configuration/defaults/backup/status create mode 100644 root/etc/e-smith/db/configuration/defaults/backup/type create mode 100644 root/etc/e-smith/db/configuration/defaults/backupwk/BackupTime create mode 100644 root/etc/e-smith/db/configuration/defaults/backupwk/Compression create mode 100644 root/etc/e-smith/db/configuration/defaults/backupwk/CompressionProg create mode 100644 root/etc/e-smith/db/configuration/defaults/backupwk/DaysInSet create mode 100644 root/etc/e-smith/db/configuration/defaults/backupwk/IncOnlyTimeout create mode 100644 root/etc/e-smith/db/configuration/defaults/backupwk/Login create mode 100644 root/etc/e-smith/db/configuration/defaults/backupwk/Password create mode 100644 root/etc/e-smith/db/configuration/defaults/backupwk/Program create mode 100644 root/etc/e-smith/db/configuration/defaults/backupwk/SetsMax create mode 100644 root/etc/e-smith/db/configuration/defaults/backupwk/SmbHost create mode 100644 root/etc/e-smith/db/configuration/defaults/backupwk/SmbShare create mode 100644 root/etc/e-smith/db/configuration/defaults/backupwk/Timeout create mode 100644 root/etc/e-smith/db/configuration/defaults/backupwk/VFSType create mode 100644 root/etc/e-smith/db/configuration/defaults/backupwk/status create mode 100644 root/etc/e-smith/db/configuration/defaults/backupwk/type create mode 100644 root/etc/e-smith/events/actions/delete-index-htm create mode 100644 root/etc/e-smith/events/actions/eject-tape create mode 100644 root/etc/e-smith/events/actions/merge-system-files create mode 100644 root/etc/e-smith/events/actions/reset-restore-idle-flag create mode 100644 root/etc/e-smith/events/actions/restore-from-disk create mode 100644 root/etc/e-smith/events/actions/rewind-tape create mode 100644 root/etc/e-smith/events/actions/save-system-files create mode 100644 root/etc/e-smith/events/actions/workstation-backup-dar create mode 100644 root/etc/e-smith/events/post-backup/.gitignore create mode 100644 root/etc/e-smith/events/pre-backup/.gitignore create mode 100644 root/etc/e-smith/locale/en-us/etc/e-smith/web/functions/backup create mode 100644 root/etc/e-smith/templates.metadata/etc/dar/CIFScredentials create mode 100644 root/etc/e-smith/templates/etc/crontab/backup create mode 100644 root/etc/e-smith/templates/etc/crontab/backupwk create mode 100644 root/etc/e-smith/templates/etc/dar/CIFScredentials/template-begin create mode 100644 root/etc/e-smith/templates/etc/dar/DailyBackup.dcf/10compression create mode 100644 root/etc/e-smith/templates/etc/dar/DailyBackup.dcf/20empty-dir create mode 100644 root/etc/e-smith/templates/etc/dar/DailyBackup.dcf/30fs-root create mode 100644 root/etc/e-smith/templates/etc/dar/DailyBackup.dcf/40go-into create mode 100644 root/etc/e-smith/templates/etc/dar/DailyBackup.dcf/45prune create mode 100644 root/etc/e-smith/templates/etc/dar/DailyBackup.dcf/50exclude create mode 100644 root/etc/e-smith/templates/etc/dar/DailyBackup.dcf/60exclude-compression create mode 100644 root/etc/e-smith/templates/etc/dar/DailyBackup.dcf/70noconf create mode 100644 root/etc/e-smith/templates/etc/dar/DailyBackup.dcf/80no-warn create mode 100644 root/etc/e-smith/templates/etc/dar/DailyBackup.dcf/90slice create mode 100644 root/etc/e-smith/templates/etc/httpd/conf/httpd.conf/97backupProxyEnv create mode 100644 root/etc/e-smith/tests/10e-smith-backup/backuphistory.conf create mode 100644 root/etc/e-smith/tests/10e-smith-backup/group-installed create mode 100644 root/etc/e-smith/tests/10e-smith-backup/group-merged create mode 100644 root/etc/e-smith/tests/10e-smith-backup/group-restored create mode 100644 root/etc/e-smith/tests/10e-smith-backup/passwd-installed create mode 100644 root/etc/e-smith/tests/10e-smith-backup/passwd-merged create mode 100644 root/etc/e-smith/tests/10e-smith-backup/passwd-restored create mode 100644 root/etc/e-smith/web/functions/backup create mode 100644 root/mnt/smb/.gitignore create mode 100644 root/sbin/e-smith/console-menu-items/usbBackup.pl create mode 100644 root/sbin/e-smith/console-menu-items/usbRestore.pl create mode 100644 root/sbin/e-smith/do_backup create mode 100644 root/sbin/e-smith/do_backupwk create mode 100644 root/usr/share/locale/en_US/LC_MESSAGES/backup.po create mode 100644 root/usr/share/perl5/vendor_perl/esmith/Backup.pm create mode 100644 root/usr/share/perl5/vendor_perl/esmith/BackupHistoryDB.pm create mode 100644 root/usr/share/perl5/vendor_perl/esmith/BlockDevices.pm create mode 100644 root/usr/share/perl5/vendor_perl/esmith/console/backup_running.pm create mode 100644 root/usr/share/perl5/vendor_perl/esmith/console/perform_backup.pm create mode 100644 root/usr/share/perl5/vendor_perl/esmith/console/perform_restore.pm create mode 100644 root/var/cache/e-smith/restore/etc/samba/.gitignore diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..e594810 --- /dev/null +++ b/.gitignore @@ -0,0 +1,4 @@ +*.rpm +*.log +*spec-20* +*.tar.xz diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..e3c1899 --- /dev/null +++ b/Makefile @@ -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) diff --git a/README.md b/README.md index 20d2caf..2e0c384 100644 --- a/README.md +++ b/README.md @@ -1,3 +1,17 @@ -# e-smith-backup +# e-smith-backup -SMEServer Koozali developed git repo for e-smith-backup smeserver \ No newline at end of file +SMEServer Koozali developed git repo for e-smith-backup smeserver + +## Wiki +
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 + +
*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* +
+ +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. diff --git a/additional/Artistic b/additional/Artistic new file mode 100644 index 0000000..5f22124 --- /dev/null +++ b/additional/Artistic @@ -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 diff --git a/additional/Copying b/additional/Copying new file mode 100644 index 0000000..eeb586b --- /dev/null +++ b/additional/Copying @@ -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. + + + Copyright (C) 19yy + + 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. + + , 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. diff --git a/additional/LICENSE b/additional/LICENSE new file mode 100644 index 0000000..0941e68 --- /dev/null +++ b/additional/LICENSE @@ -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. + diff --git a/contriborbase b/contriborbase new file mode 100644 index 0000000..ef36a67 --- /dev/null +++ b/contriborbase @@ -0,0 +1 @@ +sme10 diff --git a/createlinks b/createlinks new file mode 100644 index 0000000..03f63c4 --- /dev/null +++ b/createlinks @@ -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); + + + diff --git a/e-smith-backup.spec b/e-smith-backup.spec new file mode 100644 index 0000000..3474451 --- /dev/null +++ b/e-smith-backup.spec @@ -0,0 +1,1516 @@ +# $Id: e-smith-backup.spec,v 1.30 2023/08/14 16:51:07 jpp Exp $ + +Summary: e-smith module to provide the backup panel +%define name e-smith-backup +Name: %{name} +%define version 2.6.0 +%define release 30 +Version: %{version} +Release: %{release}%{?dist} +License: Artistic +Group: Networking/Daemons +Source: %{name}-%{version}.tar.xz + +BuildRoot: /var/tmp/%{name}-%{version}-%{release}-buildroot +BuildRequires: e-smith-devtools >= 1.11.0-03 +BuildRequires: gettext +BuildArchitectures: noarch +Requires: e-smith-base +Requires: e-smith-lib >= 1.15.1-19 +Requires: perl(Quota) +Requires: perl(Unix::PasswdFile) +Requires: perl(Crypt::PasswdMD5) +Requires: perl(Passwd::Unix) +Requires: perl(POSIX) +Requires: perl(Locale::gettext) +Requires: perl(Digest::MD5) +Requires: perl(File::Copy) +Requires: perl(esmith::I18N) +Requires: dar +Requires: cifs-utils +Requires: e-smith-formmagick >= 1.4.0-12 +Requires: nfs-utils + +%changelog +* Thu Oct 26 2023 cvs2git.sh aka Brian Read 2.6.0-30.sme +- Roll up patches and move to git repo [SME: 12338] + +* Thu Oct 26 2023 BogusDateBot +- Eliminated rpmbuild "bogus date" warnings due to inconsistent weekday, + by assuming the date is correct and changing the weekday. + +* Mon Aug 14 2023 Jean-Philippe Pialasse 2.6.0-29.sme +- fix missing files for samba in core backup [SME: 12357] + +* Sun Mar 20 2022 Terry Fage 2.6.0-28.sme +- negative date (mtime, data modification time) zerodate fix [SME: 11907] + +* Wed May 12 2021 Jean-Philippe Pialasse 2.6.0-27.sme +- allow mounting smbv1 backup share [SME: 11557] + +* Wed Apr 07 2021 Jean-Philippe Pialasse 2.6.0-25.sme +- remove lock noise to cron stdout for workstation backup [SME: 11530] + +* Fri Mar 12 2021 Jean-Philipe Pialasse 2.6.0-24.sme +- fix dar restore replacing rootdir symlinks by folders [SME: 11424] + +* Wed Feb 17 2021 Chris Sansom-Ninnes 2.6.0-23.sme +- Remove duplicate gunzip call in perform_restore [SME: 11266] + +* Fri Feb 12 2021 Chris Sansom-Ninnes 2.6.0-22.sme +- Remove debug output of device names + +* Tue Feb 9 2021 Chris Sansom-Ninnes 2.6.0-21.sme +- Revert BlockDevices.pm and backup call to not filter to removable drives + +* Sat Jan 30 2021 Chris Sansom-Ninnes 2.6.0-20.sme +- Replace hal-* calls with BlockDevices [SME: 11319] + +* Fri Jan 08 2021 Jean-Philipe Pialasse 2.6.0-19.sme +- add update event [SME: 11124] + +* Sun Jun 7 2020 Chris Sansom-Ninnes 2.6.0-17.sme +- Added /etc/backup-data.d to backup paths [SME:10245] + +* Sun May 3 2020 Chris Sansom-Ninnes 2.6.0-16.sme +- Added error handling to restore using pipe pattern from perform_backup [SME:3139] +- Made reboot optional after console restore +- Fixed bootstrap restore not activating config changes [SME:10921] +- Manually added ext2 and ext3 to Block Device file system check where ext4 present + +* Fri Apr 3 2020 Chris Sansom-Ninnes 2.6.0-14.sme +- updated Block Device discovery to fix recovery from console [SME:8244] +- Credit to Catton Durbrow + +* Mon Mar 16 2020 John Crisp 2.6.0-12.sme +- added patch for workstation backup lock [SME: 9127] +- code from Stefano Zamboni + +* Wed Apr 26 2017 Jean-Philipe Pialasse 2.6.0-11.sme +- added lock during backup to avoid multiple instance running [SME: 9127] +- code from Stefano Zamboni + +* Fri Apr 14 2017 Jean-Philipe Pialasse 2.6.0-9.sme +- added support back to ext2 and ext3 [SME: 9299] + +* Wed Apr 12 2017 Jean-Philipe Pialasse 2.6.0-8.sme +- fix removable device detection [SME: 9299] + +* Fri Feb 17 2017 Jean-Philipe Pialasse 2.6.0-7.sme +- console restoration can be launched again from console [SME: 9550] + +* Wed Aug 10 2016 stephane de Labrusse 2.6.0-6.sme +- fixed bug on the dar catalog when backups are not added in it [SME: 9563] +- Added e-smith-backup-2.6.0.bz9563.UpdateDarCatalogFollowingBackups.patch + +* Tue Aug 02 2016 stephane de Labrusse 2.6.0-5.sme +- Remove the dar exclusion message in the email if there is no exclusion. +- Modified e-smith-backup-2.6.0.Do_Dar_Exclusion.patch [SME: 9633] +- Added two commented files backup.{include,exclude} in /etc/backup-data.d +- Modified e-smith-backup-2.6.0.Add_Or_Remove_Path_In_Backup.patch [SME: 9607] + +* Sun Jul 31 2016 stephane de Labrusse 2.6.0-4.sme +- Add or remove path in your backup by a file *.include and *.exclude +- Added e-smith-backup-2.6.0.Add_Or_Remove_Path_In_Backup.patch [SME: 9607] +- Test if the remote host (cifs/nfs) is up, else save and display a warning. +- Added e-smith-backup-2.6.0.bz9090.Testing_the_remote_host_parameters.patch [SME: 9090] +- The 'tar backup to desktop' of the backup panel takes consideration of exclusion +- Added e-smith-backup-2.6.0.Do_Tar_Exclusion_In_Panel.patch [SME: 9635] +- The 'dar workstation backup' of the backup panel takes consideration of exclusion +- Added e-smith-backup-2.6.0.Do_Dar_Exclusion.patch [SME: 9633] +- The 'tar backup' of the console takes consideration of exclusion and display a page with the exclusion content +- e-smith-backup-2.6.0.Do_Tar_Exclusion_In_the_console.patch [SME: 9635] + +* Thu May 12 2016 Daniel Berteaud 2.6.0-3.sme +- Rebuild for [SME: 9393] + +* Wed Apr 13 2016 Jean-Philipe Pialasse 2.6.0-2.sme +- avoid restoration on every reboot[SME: 9436] +- Eliminated rpmbuild "bogus date" warnings due to inconsistent weekday, + by assuming the date is correct and changing the weekday. + Thu Feb 14 2001 --> Thu Feb 08 2001 or Wed Feb 14 2001 or Thu Feb 15 2001 or .... + Sat Dec 25 2005 --> Sat Dec 24 2005 or Sun Dec 25 2005 or Sat Dec 31 2005 or .... + Sat Mar 07 2008 --> Sat Mar 01 2008 or Fri Mar 07 2008 or Sat Mar 08 2008 or .... + Sat Oct 10 2010 --> Sat Oct 09 2010 or Sun Oct 10 2010 or Sat Oct 16 2010 or .... + Tue Dec 02 2013 --> Tue Nov 26 2013 or Mon Dec 02 2013 or Tue Dec 03 2013 or .... + Thu Mar 10 2014 --> Thu Mar 06 2014 or Mon Mar 10 2014 or Thu Mar 13 2014 or .... + Fri Mar 11 2014 --> Fri Mar 07 2014 or Tue Mar 11 2014 or Fri Mar 14 2014 or .... + +* Fri Feb 5 2016 Daniel Berteaud 2.6.0-1.sme +- Roll new stream for sme10 + +* Mon Oct 12 2015 stephane de Labrusse 2.4.0-44.sme +- The mountpoint is tested before to do the console backup [SME: 9089] +- added e-smith-backup-2.4.0.bz9089.Test_Backup_MountPoint.patch + +* Wed Feb 4 2015 stephane de Labrusse 2.4.0-43.sme +- Workstation Backup, do not fail backup for mtime/ctime mismatch [SME: 8800] + +* Mon Feb 2 2015 stephane de Labrusse 2.4.0-42.sme +- Change the sub checkMount() to findmnt [SME: 8502] +- Ian Wells + +* Fri Jan 9 2015 stephane de Labrusse 2.4.0-40.sme +- Add requires nfs-utils [SME: 8479] +- the nfs service is neither started or allowed to start + +* Sun Nov 2 2014 Daniel Berteaud 2.4.0-38.sme +- Don't remove the apache group during restore [SME: 8549] + +* Sat Apr 26 2014 Ian Wells 2.4.0-37.sme +- Workstation Backup, fix regression in mounting backup share [SME: 8144] + +* Thu Apr 24 2014 Ian Wells 2.4.0-36.sme +- Workstation Backup, do not create folder in / [SME: 8347] + +* Wed Apr 23 2014 Ian Wells 2.4.0-35.sme +- Workstation Backup, suppress ctime error message on incremental backups [SME: 8346] + +* Sun Apr 20 2014 Ian Wells 2.4.0-34.sme +- Implement panel and restore for backup to mounted drive [SME: 8144] + +* Sun Apr 20 2014 Ian Wells 2.4.0-33.sme +- Implement verify workstation backup for mounted drive [SME: 8144] + +* Sat Apr 19 2014 Ian Wells 2.4.0-32.sme +- Allow workstation backup to mounted drive [SME: 8144] + +* Sat Mar 15 2014 Ian Wells 2.4.0-31.sme +- Update to the latest version of perform_restore [SME: 8259] +- Boostrap console should only offer restore if no password set. + +* Tue Mar 11 2014 Ian Wells 2.4.0-30.sme + Fri Mar 11 2014 --> Fri Mar 07 2014 or Tue Mar 11 2014 or Fri Mar 14 2014 or .... +- Delete items from dar catalog in descending order [SME: 8129] +- Minor non-functional updates based on PerlCritic and review comments + +* Mon Mar 10 2014 Ian Wells 2.4.0-29.sme + Thu Mar 10 2014 --> Thu Mar 06 2014 or Mon Mar 10 2014 or Thu Mar 13 2014 or .... +- Move console backup to e-smith-backup [SME: 3324] + +* Sun Feb 9 2014 Ian Wells 2.4.0-28.sme +- Workstation Backup, selective restore of deleted files [SME: 8200] +- Remove migrate fragment 30vfstype [SME: 8199] + +* Sat Feb 8 2014 Ian Wells 2.4.0-27.sme +- Workstation Backup, Don't delete old sets, only empty them. [SME: 8195] + +* Sat Feb 8 2014 Ian Wells 2.4.0-26.sme +- Workstation Backup, Mail and WOL now subroutines [SME: 8193] +- Workstation Backup, remove the need for a temporary directory, updated. [SME: 7767] + +* Wed Feb 5 2014 Ian Wells 2.4.0-25.sme +- Workstation Backup, backupname includes seconds. [SME: 8194] +- Simplification of the time routines. + +* Wed Feb 5 2014 Ian Wells 2.4.0-24.sme +- Workstation Backup, remove the need for a temporary directory. [SME: 7767] + +* Sun Feb 2 2014 Ian Wells 2.4.0-23.sme +- Allow configuration of workstation backup if no removable disk present [SME: 7815] + +* Sun Feb 2 2014 Ian Wells 2.4.0-22.sme +- Create simplified function for updating the DarCatalog [SME: 8129] + +* Fri Jan 3 2014 Ian Wells 2.4.0-21.sme +- Workstation Backup, do not exclude dar files by default + in line with console backup. [SME: 7523] + +* Wed Dec 18 2013 Ian Wells 2.4.0-20.sme +- Further refine the text in the Backup panel [SME: 7817] +- Workstation Backup, remove tabs and whitespace changes. + +* Thu Dec 12 2013 Ian Wells 2.4.0-19.sme +- Workstation Backup, count backup sets from 1 [SME: 8059] + Set numbering patch by Dave Liquorice + +* Thu Dec 12 2013 Ian Wells 2.4.0-18.sme +- Workstation Backup, fix selective restore by requesting array + of results from CGI.pm [SME: 8057] + +* Thu Dec 12 2013 Ian Wells 2.4.0-17.sme +- Workstation Backup, new method to show files being restored is needed + when using dar 2.4 [SME: 8058] + +* Mon Dec 02 2013 Ian Wells 2.4.0-16.sme + Tue Dec 02 2013 --> Tue Nov 26 2013 or Mon Dec 02 2013 or Tue Dec 03 2013 or .... +- Allow more time for cifs mounts before reporting errors [SME: 8034] + +* Sat Nov 30 2013 Ian Wells 2.4.0-15.sme +- Simplify the workstation backup report [SME: 7791] + +* Sat Nov 30 2013 Ian Wells 2.4.0-14.sme +- Update the text in the Backup panel [SME: 7817] + +* Sun Jul 14 2013 Ian Wells 2.4.0-13.sme +- Workstation Backup, add a choice to delete old backup before or after backup [SME: 7766] + +* Sun Jul 14 2013 Ian Wells 2.4.0-12.sme +- Workstation Backup, remove temporary directory on success [SME: 7765] +- Refactor directory tree creation and removal. + +* Sun Jul 14 2013 Ian Wells 2.4.0-11.sme +- Workstation Backup, inconsistent formatting of host share name in messages [SME: 7783] + +* Sun Jul 14 2013 Ian Wells 2.4.0-10.sme +- Workstation Backup, more reliable catalog creation [SME: 7786] + +* Sat Jul 13 2013 Ian Wells 2.4.0-9.sme +- Workstation Backup, report cifs mount errors [SME: 7769] + +* Sat Jul 13 2013 Ian Wells 2.4.0-8.sme +- Workstation Backup, do not access /proc/mounts [SME: 7785] +- Incremental backup fix [SME: 7763] + +* Sat Jul 13 2013 Ian Wells 2.4.0-7.sme +- Workstation Backup, allow spaces in the backup destination [SME: 7763] + Includes fix for disk usage broken with spaces. [SME: 7784] + +* Fri Jul 5 2013 Ian Wells 2.4.0-6.sme +- Desktop Backup, allow user setting of compression level [SME: 7744] + +* Fri Jul 5 2013 Ian Wells 2.4.0-5.sme +- Use Wake on LAN before starting Backup with DAR, by Dave Liquorice [SME: 7743] + +* Mon Apr 1 2013 chris burnat 2.4.0-4.sme +- NFS syntax is deprecated for CIFS mount [SME: 7525] + +* Wed Mar 20 2013 Ian Wells 2.4.0-3.sme +- Require cifs-utils and use UNC paths for cifs mount [SME: 7503] + +* Thu Feb 28 2013 Ian Wells 2.4.0-2.sme +- Backup panel does not correctly report disk usage due to + missing ext4 support in panel code [SME: 7401] + +* Wed Feb 13 2013 Shad L. Lords 2.4.0-1.sme +- Roll new stream for sme9 +- Perl modules moved to /usr/share/perl5/vendor_perl [SME: 7223] + +* Sun Jul 08 2012 Ian Wells 2.2.0-61.sme +- Allow full backup to occur on Sunday [SME: 6876] + +* Mon Apr 9 2012 Jonathan Martens 2.2.0-60 +- Prevent selective restore timeout by creating dar catalog after backup [SME: 6052] + +* Sun Mar 04 2012 Ian Wells 2.2.0-59.sme +- Fix selective restore in modern browsers[SME: 6645] + +* Sun Jan 15 2012 Ian Wells 2.2.0-58.sme +- Remove default index.htm from Primary ibay before restore [SME: 6760] + +* Thu Dec 29 2011 Ian Wells 2.2.0-57.sme +- Additional email addresses for Workstation Backups [SME: 6783] + +* Tue Jul 19 2011 Jonathan Martens 2.2.0-56.sme +- Fix bareword TERM error introduced by 2.2.0-54 [SME: 6692] + +* Tue Jun 14 2011 Ian Wells 2.2.0-55.sme +- Do not make backup fail when due to a modified file, by Filippo Carletti [SME: 6569] + +* Sun Jun 12 2011 Ian Wells 2.2.0-54.sme +- Change kill -9 to Kill TERM [SME: 6564] +- Remove backup.orig file + +* Sun May 29 2011 Ian Wells 2.2.0-53.sme +- Remove EOL from volume labels [SME: 6605] + +* Mon Mar 21 2011 Jonathan Martens 2.2.0-52 +- Reverting previous changeset as it did more than it was supposed to do [SME: 6578] + +* Mon Mar 21 2011 Jonathan Martens 2.2.0-51 +- Fix html p entry [SME: 6578] + +* Sun Mar 20 2011 Jonathan Martens 2.2.0-50 +- Localize dropdown box of backup destination type [SME: 6575] + +* Fri Mar 18 2011 Jonathan Martens 2.2.0-49 +- Fix strings referencing USB media [SME: 5955] + +* Mon Mar 14 2011 Jonathan Martens 2.2.0-48 +- Fix strings representing sequences [SME: 5961] + +* Fri Mar 11 2011 Ian Wells 2.2.0-47.sme +- Backup to Workstation does not handle full remote disc gracefully, by Filippo Carletti [SME: 6355] + +* Sun Nov 21 2010 Jonathan Martens 2.2.0-46 +- Do not convert case of SmbShare on database migration [SME: 6387] + +* Sun Oct 10 2010 Ian Wells 2.2.0-45.sme + Sat Oct 10 2010 --> Sat Oct 09 2010 or Sun Oct 10 2010 or Sat Oct 16 2010 or .... +- Include disk usage in Workstation Backup email [SME: 6143] + +* Mon Jul 19 2010 Ian Wells 2.2.0-44.sme +- Indicate failure in Subject line of Workstation Backup [SME: 6121] + +* Fri Jul 9 2010 Ian Wells 2.2.0-43.sme +- Only define Workstation Backup temporary directory once [SME: 5930] + +* Fri Jul 9 2010 Ian Wells 2.2.0-42.sme +- Remove relocate_samba_file and all references to /etc/smbpasswd [SME: 6073] + +* Thu Jul 8 2010 Ian Wells 2.2.0-41.sme +- Remove /etc/smbpasswd from restore_list [SME: 6071] + +* Tue Jun 22 2010 Ian Wells 2.2.0-40.sme +- Update backup instructions in server-manager [SME: 6078] + +* Mon Jun 14 2010 Ian Wells 2.2.0-39.sme +- Strip spaces from Workstation Backup hostname [SME: 6060] + +* Mon Jun 14 2010 Jonathan Martens 2.2.0-38.sme +- Fix error causing restore to report failed where it was complete [SME: 6062] + +* Mon Jun 7 2010 Filippo Carletti 2.2.0-37.sme +- Check if local USB disk is mounted in backup panel [SME: 6033] + +* Thu May 13 2010 Filippo Carletti 2.2.0-36.sme +- Revert patch from 2.2.0-31: secrets.tdb still in /etc/samba [SME: 5857] + +* Tue May 11 2010 Jonathan Martens 2.2.0-35.sme +- Fix removal of leading slash in storage location [SME: 5928] + +* Sun May 9 2010 Ian Wells 2.2.0-34.sme +- Add system name in Workstation Backups email [SME: 5706] + +* Thu May 6 2010 Ian Wells 2.2.0-33.sme +- To: field missing from header in Workstation Backups email [SME: 5924] + +* Wed Mar 17 2010 Jonathan Martens 2.2.0-32.sme +- Partly revert previous patch due to undesired side effects to smbpasswd [SME: 5857] + +* Wed Mar 17 2010 Jonathan Martens 2.2.0-31.sme +- Adjust backup routines for relocation of samba secrets.tdb file [SME: 5857] + +* Mon Feb 15 2010 Stephen Noble 2.2.0-30.sme +- Improved upgrade compatibility, remove .orig [SME: 4809] + +* Fri Feb 12 2010 Stephen Noble 2.2.0-29.sme +- fix mount point for verify [SME: 5765] + +* Tue Feb 9 2010 Stephen Noble 2.2.0-28.sme +- create mount point for verify [SME: 5765] + +* Sun Jan 31 2010 Stephen Noble 2.2.0-27.sme +- remove comment re smbpasswd being last [SME: 5600] + +* Sun Jan 31 2010 Stephen Noble 2.2.0-26.sme +- Fix mounting usb disks [SME: 4809] + +* Mon Jan 25 2010 Filippo Carletti 2.2.0-25.sme +- Don't backup more than once per day [SME: 5445] + +* Wed Nov 25 2009 Filippo Carletti 2.2.0-24.sme +- Fix full backup on Sunday diplayed as Everyday [SME: 5623] + +* Fri Nov 6 2009 Jonathan Martens 2.2.0-23.sme +- Add more excludes for compressed filetypes [SME: 4765] + +* Wed Aug 26 2009 Jonathan Martens 2.2.0-22.sme +Porting Jean-Paul Leclere changes in the SME Server 7 tree to SME Server 8: +- using credentials file for cifs mount [SME: 5442] +- workstation backup: add cifs credentials expand to bootstrap-console-save [SME: 5442] + +* Sun Jul 26 2009 Jean-Paul Leclere 2.2.0-21.sme +- workstation backup: allow many backups in the same day [SME: 5411] + +* Wed Jul 22 2009 Jean-Paul Leclere 2.2.0-20.sme +- workstation restore: all needed backups must be available before restore [SME: 5397] +- workstation verify: add option to check integrity of backups needed in a full restore [SME: 5405] +- minor fix in translation [SME: 5407] + +* Sun May 17 2009 Jonathan Martens 2.2.0-19.sme +- Fix DAR e-mail message with regards to incremental backups [SME: 4579] + +* Tue Dec 9 2008 Jonathan Martens 2.2.0-18.sme +- Fix discrepancy in maximum compression level [SME: 4841] + +* Wed Oct 29 2008 Shad L. Lords 2.2.0-17.sme +- Fix spelling mistakes in backup panel [SME: 4732] +- Hide password from manager panel [SME: 4734] + +* Tue Oct 28 2008 Shad L. Lords 2.2.0-16.sme +- Migrate smbfs to cifs to complete removal [SME: 4678] + +* Mon Oct 27 2008 Shad L. Lords 2.2.0-15.sme +- Fix compression to default to gzip [SME: 4630] +- Fix uninitialized values in backup [SME: 4720] + +* Sat Oct 25 2008 Stephen Noble 2.2.0-14.sme +- dar backup to be less verbose in panel [SME: 4719] + +* Sat Oct 25 2008 Stephen Noble 2.2.0-13.sme +- correct mounting for usb disks [SME: 4695] + +* Wed Oct 22 2008 Shad L. Lords 2.2.0-12.sme +- Fix from address on email [SME: 4702] + +* Tue Oct 21 2008 Shad L. Lords 2.2.0-11.sme +- Fix patch to remove orig file [SME: 4700] +- Patch dar backup to be less verbose [SME: 4699] + +* Tue Oct 21 2008 Stephen Noble 2.0.0-10.sme +- no compression for ogg media files [SME: 4677] + +* Tue Oct 21 2008 Stephen Noble 2.2.0-8.sme +- replace defined list of directories to backup [SME: 4676] + +* Mon Oct 20 2008 Shad L. Lords 2.2.0-7.sme +- Fix already mounted check [SME: 4688] + +* Mon Oct 20 2008 Shad L. Lords 2.2.0-6.sme +- Remove obsolete smbfs backup method [SME: 4678] + +* Mon Oct 20 2008 Shad L. Lords 2.2.0-5.sme +- Use perl routines for timeout checking [SME: 4660] + +* Thu Oct 16 2008 Shad L. Lords 2.2.0-4.sme +- Make dar use defined list of directories to backup [SME: 4676] + +* Thu Oct 16 2008 Jonathan Martens 2.2.0-3.sme +- Correct translation of CONFIGURATION_TO_BE_DONE to be proper English [SME: 4669] + +* Thu Oct 9 2008 Shad L. Lords 2.2.0-2.sme +- Fix localization strings in backup panel [SME: 4650] + +* Tue Oct 7 2008 Shad L. Lords 2.2.0-1.sme +- Roll new stream to separate sme7/sme8 trees [SME: 4633] + +* Thu Aug 7 2008 Shad L. Lords 1.15.0-22 +- Localise status of workstation backup [SME: 4481] + +* Fri Aug 1 2008 Jonathan Martens 1.15.0-21 +- Fix too greedy removel of locale key CONFIGURE_TAPE_BACKUP [SME: 4469] + +* Sat Jul 26 2008 Shad L. Lords 1.15.0-20 +- Make full backups have priority over incremental [SME: 4395] + +* Sat Jul 26 2008 Shad L. Lords 1.15.0-19 +- Fix redirect to stderr on check tape cronjob [SME: 4458] + +* Mon Jul 7 2008 Jonathan Martens 1.15.0-18 +- Add common tags to e-smith-formmagick's general [SME: 4286] + +* Sat May 31 2008 Gavin Weight 1.15.0-17 +- Fix Dar manager to redirect correctly in system call. [SME: 4304] + +* Mon May 26 2008 Gavin Weight 1.15.0-16 +- Fix Dar to expand correctly. [SME: 4304] + +* Sun Apr 27 2008 Jonathan Martens 1.15.0-15 +- Add common tags to e-smith-formmagick's general [SME: 4286] + +* Wed Apr 09 2008 Stephen Noble 1.15.0-14 +- Minor fix in translation of hours [SME: 4179] + +* Tue Mar 25 2008 Shad L. Lords 1.15.0-13 +- Fix localization in restore routine [SME: 3989] + +* Fri Mar 07 2008 Stephen Noble 1.15.0-12 + Sat Mar 07 2008 --> Sat Mar 01 2008 or Fri Mar 07 2008 or Sat Mar 08 2008 or .... +- Remove
tag from error msg [SME: 3989] + +* Fri Mar 07 2008 Stephen Noble 1.15.0-11 + Sat Mar 07 2008 --> Sat Mar 01 2008 or Fri Mar 07 2008 or Sat Mar 08 2008 or .... +- Move/copy Backup_Desc to Backup_Desc_Dar for 1.15 rel [SME: 4024] + +* Wed Feb 13 2008 Stephen Noble 1.15.0-10 +- Remove tags now in general [SME: 3912] + +* Sun Feb 10 2008 Stephen Noble 1.15.0-9 +- Remove duplicate entries [SME: 3887] + +* Thu Nov 29 2007 Gavin Weight 1.15.0-8 +- Fix restore files location path. [SME: 3593] + +* Mon Nov 19 2007 Gavin Weight 1.15.0-7 +- Fix compression setting range (Thanks JPL) . [SME: 3560] + +* Fri Nov 09 2007 Gavin Weight 1.15.0-06 +- Enhancement to DAR code (Thanks JPL) . [SME: 3538] + +* Fri Oct 26 2007 Gavin Weight 1.15.0-05 +- Fix up DAR code to enable backup to complete. [SME: 3373] + +* Tue Sep 11 2007 Charlie Brady 1.15.0-04 +- Remove desktop verify and desktop restore features. Note that + lexicon entries have not been removed. [SME: 3372] + +* Fri Sep 07 2007 Charlie Brady 1.15.0-03 +- Reformat new DAR code to match existing coding style. + +* Wed Sep 05 2007 Jean-Paul Leclere 1.15.0-02 +- Dar workstation backup patch + +* Wed Sep 05 2007 Charlie Brady 1.15.0-01 +- Roll new development version. + +* Sun Jul 01 2007 Shad L. Lords 1.14.0-16 +- Remove files/dirs that don't exist from the backup list [SME: 3115] + +* Sat Jun 30 2007 Shad L. Lords 1.14.0-15 +- force proxy request to 1.0 to improve backup2desktop speed [SME: 178] + +* Sun Jun 03 2007 Gavin Weight 1.14.0-14 +- Backup to desktop changes BackupType fix. [SME 3026] + +* Sun Apr 29 2007 Shad L. Lords +- Clean up spec so package can be built by koji/plague + +* Wed Mar 07 2007 Shad L. Lords 1.14.0-13 +- Add db entry to override who gets backup reminder email [SME: 23] + +* Fri Jan 26 2007 Gordon Rowell 1.14.0-12 +- Restore group entry for machine accounts and update tests [SME: 1792] + +* Sat Jan 06 2007 Shad L. Lords 1.14.0-11 +- Change restore-from-disk to chroot tar from cpio [SME: 2318] + +* Sat Jan 06 2007 Shad L. Lords 1.14.0-10 +- Link in eject action. [SME: 795] +- Fix do_backup to actually pass backup type. [SME: 1055] + +* Fri Jan 05 2007 Shad L. Lords 1.14.0-9 +- Make tape actions depend on tape backup. [SME: 1055] +- Make backup type configurable via db. [SME: 1055] + +* Wed Jan 03 2007 Shad L. Lords 1.14.0-8 +- Add eject action and default to no. [SME: 795] + +* Thu Dec 07 2006 Shad L. Lords +- Update to new release naming. No functional changes. +- Make Packager generic + +* Wed Nov 08 2006 Charlie Brady 1.14.0-06 +- Use tarsize not dumpsize to determine when backup is too large. + [SME: 2041] + +* Wed Apr 5 2006 Gordon Rowell 1.14.0-05 +- Fix typo in crontab template for 'disabled' case [SME: 1092] + +* Wed Apr 5 2006 Gordon Rowell 1.14.0-04 +- Move /etc/cron.d/backup into /etc/crontab fragment [SME: 1172] +- Expand /etc/crontab in conf-backup. e-smith-base already does + it for us in bootstrap-console-save [SME: 1172] +- Remove /etc/cron.d/backup in post [SME: 1172] + +* Wed Mar 15 2006 Gordon Rowell 1.14.0-03 +- Add semi-colon to last code change. Saves head-scratching if + someone removes the braces at some later stage. [SME: 1045] + +* Wed Mar 15 2006 Gordon Rowell 1.14.0-02 +- Add warning about desktop backup if the server has more than + 2GB of data. [SME: 1045] + +* Tue Mar 14 2006 Charlie Brady 1.14.0-01 +- Roll stable stream version. [SME: 1016] + +* Sun Mar 12 2006 Charlie Brady 1.13.4-10 +- Another fix to restore-from-disk script. [SME: 821] + +* Thu Feb 16 2006 Charlie Brady 1.13.4-09 +- Fix restore-from-disk script. [SME: 821] + +* Mon Feb 6 2006 Charlie Brady 1.13.4-08 +- Fix 24->12 hour time display problem (courtesy of Federico Simoncelli). + [SME: 667] + +* Wed Feb 01 2006 Charlie Brady 1.13.4-07 +- Add restore-from-disk script. [SME: 615] + +* Sun Dec 25 2005 Gordon Rowell 1.13.4-06 + Sat Dec 25 2005 --> Sat Dec 24 2005 or Sun Dec 25 2005 or Sat Dec 31 2005 or .... +- Don't delete config dbs in pre-restore [SME: 229] + +* Tue Dec 06 2005 Filippo Carletti 1.13.4-05 +- Tape reminder uses mt status to check if tape loaded [SME: 251] + +* Wed Nov 30 2005 Gordon Rowell 1.13.4-04 +- Bump release number only + +* Tue Nov 1 2005 Charlie Brady +- [1.13.4-03] +- Improve user feedback if pre-backup or pre-restore events fail. [SF: 1334923] + +* Mon Oct 24 2005 Charlie Brady +- [1.13.4-02] +- Create empty /etc/e-smith/db/backups directory to trigger migration + to new location. [SF: 1335862] + +* Fri Oct 14 2005 Gordon Rowell +- [1.13.4-01] +- Remove L10Ns from base packages [SF: 1309520] + +* Fri Oct 14 2005 Gordon Rowell +- [1.13.3-01] +- New dev stream before relocating L10Ns + +* Fri Sep 30 2005 Gordon Rowell +- [1.13.2-17] +- Added Italian L10N - Thanks Filippo Carletti [SF: 1309266] + +* Sun Sep 25 2005 Gordon Rowell +- [1.13.2-16] +- Added German L10N - Thanks Dietmar Berteld [SF: 1293325] + +* Sun Sep 18 2005 Charlie Brady +- [1.13.2-15] +- Remove explict use of CGI (which caused double construction of + the CGI object, and loss of uploaded data file). [SF: 1264699] + +* Fri Sep 16 2005 Charlie Brady +- [1.13.2-14] +- Don't delete configuration dbs in pre-restore event until + we have finished using them. [SF: 1292448] + +* Tue Aug 30 2005 Charlie Brady +- [1.13.2-13] +- Really add delete-configuration-dbs action. [SF: 1246347,1275962] + +* Fri Aug 19 2005 Gordon Rowell +- [1.13.2-12] +- Delete configuration dbs from /home/e-smith/db/ prior to + a restore to ensure that the ones coming from tape are the + only ones on the system after the restore [SF: 1246347] + +* Tue Aug 9 2005 Charlie Brady +- [1.13.2-11] +- Restore passwd file entries for machine accounts. [SF: 1254663] + +* Fri Jul 22 2005 Charlie Brady +- [1.13.2-10] +- Enforce Posix behaviour of df command, in restore functions of panel. + [SF: 1242986] + +* Tue Jul 19 2005 Charlie Brady +- [1.13.2-09] +- Remove last deprecated esmith::config API calls. [SF: 1216546] + +* Mon Jul 18 2005 Charlie Brady +- [1.13.2-08] +- Remove explicit paths to db files. [SF: 1216546] + +* Fri Apr 29 2005 Charlie Brady +- [1.13.2-07] +- Remove another anacronistic version requires in perl library. + Grrrr!!! [charlieb MN00050370] + +* Tue Mar 8 2005 Charlie Brady +- [1.13.2-06] +- Use generic_template_expand action in place of conf-backup. + Update e-smith-lib dependency. [MN00064130] + +* Tue Mar 8 2005 Charlie Brady +- [1.13.2-05] +- Ensure that smbpasswd file appears last in list during restore/verification. + [MN00073362] +- Fix merging of samba files. [MN00073365] + +* Mon Nov 8 2004 Charlie Brady +- [1.13.2-04] +- Explicitly list required perl modules - RPM didn't work it out correctly. + [charlieb MN00050751] + +* Tue Sep 28 2004 Charlie Brady +- [1.13.2-03] +- Remove deprecated "require v5.6.0". [charlieb MN00050370] +- Allow RPM to work out what the perl Requires headers should be. + [charlieb MN00050751] + +* Thu Sep 16 2004 Michael Soulier +- [1.13.2-02] +- Fixed Content-disposition header. [msoulier MN00049326] + +* Sat Jun 19 2004 Michael Soulier +- [1.13.2-01] +- skipping mps branch start - 1.13.2 + +* Fri May 21 2004 Michael Soulier +- [1.13.0-06] +- Added /etc/samba/secrets.tdb to the restore list. [msoulier MN00020969] + +* Mon Mar 1 2004 Michael Soulier +- [1.13.0-05] +- Updated do_backup to pass a "tape" argument when using signal-event + and rewind-tape to exit if a second argument is not given. + [msoulier dpar-22041] + +* Wed Jan 14 2004 Michael Soulier +- [1.13.0-04] +- Added /etc/sudoers to backup list for desktop backup. [msoulier 4954] + +* Fri Nov 28 2003 Michael Soulier +- [1.13.0-03] +- Display big-red reboot warning like other panels. Wow, it's hard to miss + now. [msoulier 10240] + +* Fri Nov 28 2003 Mark Knox +- [1.13.0-02] +- Display reboot warning and button after successful desktop restore [markk + 1312] + +* Thu Nov 6 2003 Michael Soulier +- [1.13.0-01] +- rolling to dev stream - 1.13.0 + +* Thu Sep 11 2003 Gordon Rowell +- [1.12.1-02] +- Relocate /etc/secrets.tdb to /etc/samba [gordonr 9759] + +* Wed Sep 3 2003 Gordon Rowell +- [1.12.1-01] +- Rebuild [gordonr 1305] + +* Wed Sep 3 2003 Gordon Rowell +- [1.12.0-09] +- Adjusted Copyright [gordonr 1305] + +* Mon Jul 14 2003 Gordon Rowell +- [1.12.0-08] +- Whitespace fix in Backup.pm [gordonr 9428] + +* Mon Jul 14 2003 Charlie Brady +- [1.12.0-07] +- Remove /etc/samba/smbpasswd symlink if we find it, before doing + the move/symlink shuffle with smbpasswd files. This prevents us + "preserving" old symlinks. [charlieb 9416] + +* Mon Jul 14 2003 Gordon Rowell +- [1.12.0-06] +- Rename the pre-restore cache files in $file.time(). This preserves + them in case we want to wander back through them after an + upgrade, and ensures that they won't be around to confuse another + post-upgrade [gordonr 9428] + +* Wed Jul 9 2003 Gordon Rowell +- [1.12.0-05] +- Handle the "everything o.k. with relocation" case [gordonr 9333] + +* Wed Jul 9 2003 Gordon Rowell +- [1.12.0-04] +- Further safeguards for the /etc/smbpasswd -> /etc/samba/smbpasswd + relocation [gordonr 9333] + +* Fri Jun 27 2003 Charlie Brady +- [1.12.0-03] +- Fix backup panel text change. Made text non-specific about the location of + the smbpasswd file. [charlieb 9220] + +* Fri Jun 27 2003 Charlie Brady +- [1.12.0-02] +- Account for the path change of smbpasswd file in desktop restore/verify. + [charlieb 9220] + +* Thu Jun 26 2003 Charlie Brady +- [1.12.0-01] +- Changing version to stable stream number - 1.12.0 + +* Tue Jun 24 2003 Gordon Rowell +- [1.11.1-04] +- Spanish nav bar [gordonr 9153] + +* Fri Jun 13 2003 Gordon Rowell +- [1.11.1-03] +- Corrected logic for switching /etc{/samba,}/smbpasswd [gordonr 8747] + +* Thu Jun 12 2003 Charlie Brady +- [1.11.1-02] +- Remove some remnants of templated /sbin/e-smith/backup. +- Use Backup program parameter in /sbin/e-smith/do_backup. + [charlieb 7853] + +* Thu Jun 12 2003 Charlie Brady +- [1.11.1-01] +- Roll new development stream to 1.11.1 + +* Wed May 28 2003 Gordon Rowell +- [1.11.0-56] +- And symlink /etc/smbpasswd to avoid confusion [gordonr 8809] +- Move guard so we skip if /etc/smbpasswd is not a file [gordonr 8809] + +* Wed May 28 2003 Gordon Rowell +- [1.11.0-55] +- Migrate /etc/smbpasswd to /etc/samba/smbpasswd after restore [gordonr 8809] + +* Wed May 21 2003 Gordon Rowell +- [1.11.0-54] +- Fix return check for ->group and ->passwd [gordonr 8766] +- Fix tests for BackupHistoryDB.pm [gordonr 5908, in passing] + +* Tue May 20 2003 Gordon Rowell +- [1.11.0-53] +- Extract the tests at build time [gordonr 8766] + +* Tue May 20 2003 Gordon Rowell +- [1.11.0-52] +- Completed merge_group and tests, including admin, www, shared [gordonr 8766] + +* Fri May 16 2003 Gordon Rowell +- [1.11.0-51] +- Added test files and skeleton for merge_group [gordonr 8766] +- TODO: Complete merge_group and tests [gordonr 8766] +- TODO: Handle admin, www, shared groups [gordonr 8766] + +* Fri May 16 2003 Gordon Rowell +- [1.11.0-50] +- Further work, and tests, for merge_passwd [gordonr 8766] + +* Fri May 16 2003 Gordon Rowell +- [1.11.0-49] +- Code cleanups [gordonr 8766] + +* Fri May 16 2003 Gordon Rowell +- [1.11.0-48] +- Constructors are nice to have in objects :-( [gordonr 8766] +- Link merge-system-files into post-upgrade [gordonr 8766] + +* Fri May 16 2003 Gordon Rowell +- [1.11.0-47] +- Added esmith::Backup::{save,merge}_system_files [gordonr 8766] + +* Fri May 16 2003 Gordon Rowell +- [1.11.0-46] +- Modified backup panel to use esmith::Backup library [gordonr 8766] + +* Fri May 16 2003 Gordon Rowell +- [1.11.0-45] +- Added esmith::Backup library to centralise list of files/directories to + restore [gordonr 8766] +- Save away important system files in pre-restore [gordonr 8766] + +* Tue May 6 2003 Mark Knox +- [1.11.0-44] +- Pass the right type of object to genResult [markk 8498] + +* Tue May 6 2003 Lijie Deng +- [1.11.0-43] +- Add Spanish translation for backup [lijied 3793] + +* Tue Apr 29 2003 Trevor Poole +- [1.11.0-42] +- add the BackupType to the record for the desktop case. [trevor 5908] + +* Mon Apr 28 2003 Charlie Brady +- [1.11.0-41] +- Fix calls to create new backup records. [charlieb 5908] + +* Mon Apr 28 2003 Charlie Brady +- [1.11.0-40] +- Record each backup attempt separately in a backup history db. [charlieb 5908] + +* Wed Apr 23 2003 Charlie Brady +- [1.11.0-39] +- Record success or otherwise of backup to desktop attempts in config db. + [charlieb 5908] +- Gracefully handle SIGPIPE in backup to desktop. [charlieb 8490] + +* Wed Apr 23 2003 Charlie Brady +- [1.11.0-38] +- Fix typo in rewind-tape fix. [charlieb 8475] + +* Wed Apr 23 2003 Charlie Brady +- [1.11.0-37] +- Call signal-event {pre,post}-backup with extra "desktop" parameter + from desktop backup code, and use that parameter to skip tape rewinding. + [charlieb 7853] +- Fix device lookup code in rewind-tape action. [charlieb 8475] + +* Wed Apr 23 2003 Charlie Brady +- [1.11.0-36] +- Fix a few semantic problems with reset--restore-idle-flag script. + [charlieb 8466] + +* Wed Apr 16 2003 Michael Soulier +- [1.11.0-35] +- Replaced bad call to processTemplate. [msoulier 7600] + +* Wed Apr 9 2003 Charlie Brady +- [1.11.0-34] +- Remove deprecated /sbin/e-smith/backup in %post script. + [charlieb 7853] + +* Tue Apr 8 2003 Charlie Brady +- [1.11.0-33] +- Fix typo in rewind-tape action. [charlieb 5908] +- Change Copyright => License in header. + +* Fri Apr 4 2003 Mark Knox +- [1.11.0-32] +- Removed redundant refs to bootstrap-console from panel [markk 6164] + +* Thu Apr 3 2003 Tony Clayton +- [1.11.0-31] +- Change table to start_table where applicable [tonyc 8034] + +* Thu Apr 3 2003 Tony Clayton +- [1.11.0-30] +- Removed "Mitel Network SME server' branding [lijied 8016] +- Fix layout/css in backup panel [tonyc 7950] + +* Mon Mar 31 2003 Charlie Brady +- [1.11.0-29] +- Re-write do_backup in perl. [charlieb 5908] + +* Fri Mar 28 2003 Lijie Deng +- [1.11.0-28] +- Modified directory po/fr_CA to fr [lijied 6787] + +* Thu Mar 27 2003 Gordon Rowell +- [1.11.0-27] +- Modified gettext() extraction based on changes in 1.11.0-25 [gordonr 5908] + +* Thu Mar 27 2003 Gordon Rowell +- [1.11.0-26] +- Call genFooter/genResult with an FM object (subclass of CGI) so + footers get localised [gordonr 3553] + +* Thu Mar 27 2003 Charlie Brady +- [1.11.0-25] +- Remove templated /sbin/e-smith/backup and add non-templated + do_backup script. Alter cron template to suit. Move tape + rewind into pre-backup and post-backup actions. Log + start, finish and result properties from backup script. + [charlieb 5908] + +* Thu Mar 27 2003 Lijie Deng +- [1.11.0-24] +- Modified French lexicon to use lang="fr", rename the lexicon + directory to fr [lijied 6787] + +* Tue Mar 25 2003 Tony Clayton +- [1.11.0-23] +- Add link to fr-ca PAGE_REFRESH_IN translation [tonyc 6491] + +* Tue Mar 18 2003 Lijie Deng +- [1.11.0-22] +- Deleted ./sbin/e-smith/backup/template-begin, and modified + %build [lijied 3295] + +* Fri Mar 14 2003 Michael Soulier +- [1.11.0-21] +- Changed the post restore code such that the backup panel is blocked until + the server reboots. [msoulier 6471] + +* Mon Mar 10 2003 Lijie Deng +- [1.11.0-20] +- Modified charset tag in .po file [lijied 3930] + +* Fri Mar 7 2003 Lijie Deng +- [1.11.0-19] +- Modified e-smith-devtools again [lijied 7578] + +* Fri Mar 7 2003 Lijie Deng +- [1.11.0-18] +- Modified e-smith-devtools version [lijied 7578] + +* Thu Mar 6 2003 Lijie Deng +- [1.11.0-17] +- Added the generate lexicon code [lijied 7442] + +* Thu Mar 6 2003 Lijie Deng +- [1.11.0-16] +- Added the .po file to po/fr_CA again [lijied 7442] + +* Thu Mar 6 2003 Lijie Deng +- [1.11.0-15] +- Cleaned up .po->.mo build [lijied 7442] + +* Thu Mar 6 2003 Lijie Deng +- [1.11.0-14] +- Added .po->.mo instructions to %build [lijied 7442] + +* Thu Mar 6 2003 Lijie Deng +- [1.11.0-13] +- Modified backup panel order [lijied 7356] + +* Tue Mar 4 2003 Lijie Deng +- [1.11.0-12] +- Remodify the lexicon file [lijied 4030] + +* Tue Mar 4 2003 Lijie Deng +- [1.11.0-11] +- Split en-us lexicon from backup panel [lijied 4030] + +* Fri Feb 28 2003 Lijie Deng +- [1.11.0-10] +- Rebuild RPM - commit missed last time [lijied 5003] + +* Fri Feb 28 2003 Lijie Deng +- [1.11.0-09] +- Added French lexicon for backup [lijied 5003] + +* Wed Jan 1 2003 Gordon Rowell +- [1.11.0-08] +- Rewrote template to use esmith::I18N [gordonr 5212] + +* Fri Dec 13 2002 Mark Knox +- [1.11.0-07] +- Added "click here" text on tape restore page [markk 6094] + +* Thu Dec 12 2002 Mark Knox +- [1.11.0-06] +- Removed redundant success message after restore [markk 6094] + +* Thu Dec 12 2002 Mark Knox +- [1.11.0-05] +- Added refresh and status messages to tape restore process [markk 6094] + +* Tue Dec 3 2002 Charlie Brady +- [1.11.0-04] +- Tidy up and update /sbin/e-smith/backup templates, preparatory to adding + support for non-tape devices. [charlieb 5521] + +* Mon Dec 2 2002 Mike Dickson +- [1.11.0-03] +- ui update [miked 5494] + +* Thu Nov 21 2002 Mike Dickson +- [1.11.0-02] +- update to new UI system [miked 5494] + +* Wed Nov 6 2002 Charlie Brady +- [1.11.0-01] +- Rolling development stream version to 1.11.0 + +* Tue Oct 15 2002 Charlie Brady +- [1.10.1-01] +- New checkout to force head revisions to 1.10.1 + +* Fri Oct 11 2002 Charlie Brady +- [1.10.0-01] +- Roll to maintained version number to 1.10.0 + +* Fri Oct 11 2002 Gordon Rowell +- [1.9.0-09] +- Added missing closing paren - code police needed earlier [gordonr 5168] + +* Fri Oct 11 2002 Gordon Rowell +- [1.9.0-08] +- Renamed duplicate lexicon tag RESTORE_IN_PROGRESS{,_BEGAN_AT} + RESTORE_IN_PROGRES_DESC -> MUST_REBOOT_AFTER_RESTORE in tape restore + [gordonr 5168] + +* Wed Oct 9 2002 Mike Dickson +- [1.9.0-07] +- Fixed double call of pre-restore [miked 5158] + +* Wed Oct 9 2002 Mike Dickson +- [1.9.0-06] +- Fixed references to ext2 filesystem in CalculateSizes; cahnged them to ext3 + +* Wed Sep 25 2002 Charlie Brady +- [1.9.0-05] +- Add calls to signal-event pre-restore before tape or desktop restore + (currently to stop slapd and remove LDIF dump file). [charlieb 2745] + +* Mon Sep 23 2002 Charlie Brady +- [1.9.0-04] +- Fix XML errors in backup panel. [charlieb 2745] + +* Fri Sep 20 2002 Charlie Brady +- [1.9.0-03] +- Complete previous change - the web panel needed to be updated as well. + [charlieb 2745] + +* Thu Aug 29 2002 Charlie Brady +- [1.9.0-02] +- Change mysql-dump-tables and mysql-delete-dumps events to pre-backup and + post-backup events. [charlieb 2745] + +* Wed Jun 5 2002 Charlie Brady +- [1.9.0-01] +- Changing version to development stream number to 1.9.0 + +* Fri May 31 2002 Tony Clayton +- [1.8.2-01] +- Reverting previous change - "it's a feature" [tonyc 3746] + +* Fri May 31 2002 Tony Clayton +- [1.8.1-01] +- Prevent tape/destop restores from dieing in state=running [tonyc 3746] + +* Fri May 31 2002 Charlie Brady +- [1.8.0-01] +- Changing version to maintained stream number to 1.8.0 + +* Fri May 31 2002 Mark Knox +- [1.7.20-01] +- Fixed some funny table cells that were causing trouble in Netscape + [markk 3764] + +* Fri May 31 2002 Charlie Brady +- [1.7.19-01] +- Removed unused config db tie in restore-idle-flag. +- Add initialisation of backup service entry in config db. + This will allow restore from tape to work out of the box. + [charlieb 1254, 3746] + +* Wed May 29 2002 Tony Clayton +- [1.7.18-01] +- Fix bad string concats in /sbin/e-smith/backup fragments [tonyc 3180] + +* Thu May 23 2002 Gordon Rowell +- [1.7.17-01] +- RPM rebuild forced by cvsroot2rpm + +* Thu May 23 2002 Gordon Rowell +- [1.7.16-01] +- testing co2rpm --force + +* Thu May 23 2002 Gordon Rowell +- [1.7.15-01] +- testing co2rpm --force + +* Thu May 23 2002 Gordon Rowell +- [1.7.14-01] +- testing co2rpm --force + +* Thu May 23 2002 Gordon Rowell +- [1.7.13-01] +- testing co2rpm --force + +* Sat May 18 2002 Gordon Rowell +- [1.7.12-01] +- Changed quoting in /etc/crond.d/backup template [gordonr 3029] + +* Sat May 18 2002 Gordon Rowell +- [1.7.11-01] +- "Verify complete" -> "Verification is complete" [gordonr 3544] + +* Wed May 8 2002 Mark Knox +- [1.7.10-01] +- Allow form uploads and large files to be posted. [markk 3159] + +* Wed May 8 2002 Mark Knox +- [1.7.9-01] +- Localised a few more strings in sbin/e-smith/backup templates [markk 3029] + +* Wed May 1 2002 Gordon Rowell +- [1.7.8-01] +- esmith::AccountDB -> esmith::AccountsDB [schwern 3287] + +* Tue Apr 16 2002 Mark Knox +- [1.7.7-01] +- I18n backup cronjob using gettext. Also converted to ConfigDB. [markk 3029] + +* Mon Apr 15 2002 Gordon Rowell +- [1.7.7-01] +- Language en->en-us + +* Fri Apr 12 2002 Mark Knox +- [1.7.6-01] +- Internationalized using FormMagick lexicon [markk 3159] +- Converted to esmith::ConfigDB API [markk 3159] + +* Fri Mar 15 2002 Charlie Brady +- [1.7.5-01] +- Include "du -s " of all backed up files and directories other than + /home/e-smith in desktop backup estimate. + +* Thu Mar 14 2002 Charlie Brady +- [1.7.4-01] +- Fix error in use of AccountsDB interface (#2139). + +* Thu Mar 07 2002 Charlie Brady +- [1.7.3-01] +- Include /root in desktop backup and in size estimate (#2322). +- Change text to indicate that desktop backup file will be somewhat + smaller if files are compressible. + +* Thu Mar 07 2002 Charlie Brady +- [1.7.2-01] +- Use Quota module to estimate desktop backup size, by summing over all + user accounts (#2139). + +* Wed Feb 27 2002 Jason Miller +- [1.7.1-01] +- Rolled to version 1.7.1-01 to verify CVS contents from 1.7.0-01. + Includes all patchesup to 1.7.0-01. + +* Wed Feb 27 2002 Jason Miller +- [1.7.0-01] +- rollRPM: Rolled version number to 1.7.0-01. Includes patches up to 1.6.0-01. + +* Tue Dec 11 2001 Adrian Chung +- [1.6.0-01] +- rollRPM: Rolled version number to 1.6.0-01. Includes patches up to 1.5.0-04. + +* Thu Dec 6 2001 Adrian Chung +- [1.5.0-04] +- Adding text to restore screen that warns that your restore + is not complete until you see the words Restore complete and + /etc/smbpasswd is restored. + +* Wed Nov 28 2001 Charlie Brady +- [1.5.0-03] +- Report restore/verify problems if they are detected. Do not do any + post processing unless the restore completes successfully. + +* Tue Nov 13 2001 Tony Clayton +- [1.5.0-02] +- adding last patch to prep section. feels like monday. + +* Tue Nov 13 2001 Tony Clayton +- [1.5.0-01] +- Rolled version number to 1.5.0-01. Includes patches up to 1.4.0-06. +- use esmith::lockfile for lockfile stuff +- add dependency on e-smith-lib >= 1.7.0-20 for esmith::lockfile + +* Tue Nov 13 2001 Tony Clayton +- [1.4.0-06] +- backing out lockfile patch - moving to new stream + +* Mon Nov 12 2001 Tony Clayton +- [1.4.0-05] +- use esmith::lockfile for lockfile stuff +- add dependency on e-smith-lib >= 1.7.0-20 for esmith::lockfile + +* Wed Nov 07 2001 Tony Clayton +- [1.4.0-04] +- rebranding to Mitel Networks + +* Fri Aug 17 2001 Gordon Rowell +- [1.4.0-03] +- Changed default network backup filename to "smeserver.tar.xz" +- Note: We can still restore the old format "esmithsg.bak" files + +* Fri Aug 17 2001 gordonr +- [1.4.0-02] +- Autorebuild by rebuildRPM + +* Wed Aug 8 2001 Charlie Brady +- [1.4.0-01] +- Rolled version number to 1.4.0-01. Includes patches upto 1.3.0-10. + +* Thu Aug 02 2001 Gordon Rowell +- [1.3.0-10] +- More branding changes + +* Thu Aug 02 2001 Gordon Rowell +- [1.3.0-09] +- More branding changes + +* Tue Jul 31 2001 Jason Miller +- [1.3.0-08] +- Branding/marketing text changes email/e-mail + +* Sun Jul 29 2001 Jason Miller +- [1.3.0-07] +- Branding text changes to the backup web panel + +* Fri Jul 6 2001 Peter Samuel +- [1.3.0-06] +- Changed license to GPL + +* Wed Jul 04 2001 Gordon Rowell +- [1.3.0-05] +- Default to .tar.xz for desktop backup/restore/verify +- Allow uuencoded tar (esmithsg.bak) for restore/verify backwards compatability + +* Thu Jun 07 2001 Gordon Rowell +- [1.3.0-04] +- Add --verbose to tar --extract so web panels shows restored files + +* Thu Jun 07 2001 Charlie Brady +- [1.3.0-03] +- Add option to verify desktop backup file contents. + +* Thu Jun 07 2001 Charlie Brady +- [1.3.0-02] +- Avoid use of redundant temporary file, CGI.pm already creates one for us, + and provides us with a file handle. + +* Wed Apr 11 2001 Adrian Chung +- [1.3.0-01] +- Rolled version number to 1.3.0-01. Includes patches upto 1.2.0-11. + +* Wed Feb 21 2001 Charlie Brady +- [1.2.0-11] +- Add tape rewind action to tape restore + +* Wed Feb 21 2001 Peter Samuel +- [1.2.0-10] +- Now rewinds tape before zeroing tape. +- Writes 32k of zeroes instead of 10k. + +* Wed Feb 14 2001 Charlie Brady + Thu Feb 14 2001 --> Thu Feb 08 2001 or Wed Feb 14 2001 or Thu Feb 15 2001 or .... +- [1.2.0-09] +- Add conf-backup to bootstrap-console-save. +- Don't need templates-user-custom directory now, it's in e-smith-base RPM. + +* Mon Feb 12 2001 Peter Samuel +- [1.2.0-08] +- Duping STDOUT fails for netscape. Now just redirecting STDOUT to STDERR. + +* Mon Feb 12 2001 Adrian Chung +- [1.2.0-07] +- rolling release number for GPG signing. + +* Sun Feb 11 2001 Charlie Brady +- [1.2.0-06] +- Include etc/e-smith/templates-user-custom in backup + +* Thu Feb 8 2001 Adrian Chung +- Rolling release number for GPG signing. + +* Thu Feb 8 2001 Peter Samuel +- [1.2.0-04] +- Zero pad minutes for backup and reminder times. +- Fix nasty problem stopping flexbackup running in the background. + Needed to dup STDOUT, close STDOUT, and reset STDOUT to duped fd. + +* Tue Jan 30 2001 Peter Samuel +- [1.2.0-03] +- Changed size calculations so that minimum size displayed is 1Mb. +- Changed wording of size of snapshot. +- Notify user how much free space exists in /tmp. +- Remove uploaded file after restore. + +* Mon Jan 29 2001 Charlie Brady +- [1.2.0-02] +- Preserve gid of www across restore. +- Add comment about upbuffering output + +* Thu Jan 25 2001 Peter Samuel +- [1.2.0-01] +- Rolled version number to 1.2.0-01. Includes patches upto 1.1.0-17. + +* Thu Jan 25 2001 Peter Samuel +- [1.1.0-17] +- Added html output to reboot function of manager panel + +* Wed Jan 24 2001 Peter Samuel +- [1.1.0-16] +- /sbin/e-smith/backup zeroes tape before starting. This is a hack to + work around talking to ide tapes via ide-scsi. + +* Wed Jan 17 2001 Peter Samuel +- [1.1.0-15] +- mysql tables are deleted before and after backups and restores + +* Tue Jan 16 2001 Peter Samuel +- [1.1.0-14] +- cron job now runs every day + +* Mon Jan 15 2001 Peter Samuel +- [1.1.0-13] +- removed unnecessary /sbin/e-smith/tape-restore template +- fixed html formatting problem in backup panel +- fixed backgrounding problem in backup panel - need to close STDOUT in child +- format fixes in backup panel + +* Mon Jan 15 2001 Jason Miller +- [1.1.0-12] +- Changes to the menu item ordering for the e-smith manager + +* Sat Jan 13 2001 Peter Samuel +- [1.1.0-11] +- Changed fork and signal handling again - doesn't seem to make much + difference. Could be the lock file interaction - needs testing. + +* Sat Jan 13 2001 Peter Samuel +- [1.1.0-10] +- Fixed order of files to be restored +- Moved signal handling but it makes no difference, still can't background + +* Sat Jan 13 2001 Peter Samuel +- [1.1.0-09] +- /sbin/e-smith/backup now dumps mysql tables to /home/e-smith prior + to running the tape backup + +* Sat Jan 13 2001 Peter Samuel +- [1.1.0-08] +- fixed uninitialised variables +- reboot action calls backgroundCommand instead of showing new panel + +* Sat Jan 13 2001 Peter Samuel +- [1.1.0-07] +- fixed syntax error in /etc/e-smith/events/actions/conf-backup + +* Fri Jan 12 2001 Peter Samuel +- [1.1.0-06] +- flexbackup is merely the default backup program +- cron job calls /sbin/e-smith/backup which is a templated file +- restore-tape action now given to flexbackup as it is flexbackup specific + +* Fri Jan 12 2001 Peter Samuel +- [1.1.0-05] +- Removed checks for uptime. The state in /etc/e-smith/restore is not + changed, regardless of reboots. It is changed by bootstrap-console. +- Lots of text changes for consistency and to reinforce the need to + reboot after a restore +- Mail is sent to the admin user after a tape restore indicating + success or failure. +- mysql tables are dumped to /home/e-smith prior to network backup. +- Calculation of tarsize handles negative values sensibly. + +* Fri Jan 12 2001 Peter Samuel +- [1.1.0-04] +- No longer checks for current state of EthernetDrive1 and LocalIP. +- Does not do a forced reboot under any circumstances. +- Calls post-upgrade after the restore instead of post-restore. + +* Thu Jan 11 2001 Peter Samuel +- [1.1.0-03] +- Major changes to panel. Now does tape restore in background. Lots of + checks and balances to avoid concurrent restores/backups etc. + +* Wed Jan 10 2001 Jason Miller +- [1.1.0-02] +- Minor change to the copyright for consistency + +* Tue Jan 9 2001 Peter Samuel +- [1.1.0-01] +- Rolled version to 1.1.0-01. Includes patches upto 0.1-4 + +* Mon Jan 8 2001 Peter Samuel +- [0.1-4] +- Now restores config from tape + +* Sun Jan 7 2001 Jason Miller +- [0.1-2] through [0.1-3] +- completed the update section for configuration database + of flexbackup +- prepared the restore-tape option for the call to the + proper event for restoring from tape + +* Sun Jan 7 2001 Jason Miller +- initial release + +%description +e-smith server central backup administration panel + +%prep +%setup + +%build +/sbin/e-smith/buildtests 10e-smith-backup +%{__mkdir} -p root/etc/backup-data.d +perl createlinks + +# Extract a new copy of the English .po, though we won't use it for this build +xgettext -o root/usr/share/locale/en_US/LC_MESSAGES/backup.po \ + root/etc/e-smith/templates/etc/crontab/backup \ + root/sbin/e-smith/do_backup + +/sbin/e-smith/generate-lexicons + +%install +rm -rf $RPM_BUILD_ROOT +(cd root ; find . -depth -print | cpio -dump $RPM_BUILD_ROOT) +rm -f %{name}-%{version}-%{release}-filelist +/sbin/e-smith/genfilelist $RPM_BUILD_ROOT \ + > %{name}-%{version}-%{release}-filelist +echo "%doc Copying" >> %{name}-%{version}-%{release}-filelist +echo "%doc Artistic" >> %{name}-%{version}-%{release}-filelist +echo "%doc LICENSE" >> %{name}-%{version}-%{release}-filelist + +%clean +rm -rf $RPM_BUILD_ROOT + +%files -f %{name}-%{version}-%{release}-filelist +%defattr(-,root,root) diff --git a/root/etc/backup-data.d/backup.exclude b/root/etc/backup-data.d/backup.exclude new file mode 100644 index 0000000..166a9c7 --- /dev/null +++ b/root/etc/backup-data.d/backup.exclude @@ -0,0 +1,2 @@ +# All folder/file paths added here will NOT be saved +# For Example : /usr/share/wordpress/config diff --git a/root/etc/backup-data.d/backup.include b/root/etc/backup-data.d/backup.include new file mode 100644 index 0000000..31ae288 --- /dev/null +++ b/root/etc/backup-data.d/backup.include @@ -0,0 +1,2 @@ +# All folder/file paths added here will be saved +# For Example : /usr/share/wordpress diff --git a/root/etc/dar/.gitignore b/root/etc/dar/.gitignore new file mode 100644 index 0000000..e69de29 diff --git a/root/etc/e-smith/db/backups/.gitignore b/root/etc/e-smith/db/backups/.gitignore new file mode 100644 index 0000000..e69de29 diff --git a/root/etc/e-smith/db/configuration/defaults/backup/BackupType b/root/etc/e-smith/db/configuration/defaults/backup/BackupType new file mode 100644 index 0000000..5c15e34 --- /dev/null +++ b/root/etc/e-smith/db/configuration/defaults/backup/BackupType @@ -0,0 +1 @@ +tape diff --git a/root/etc/e-smith/db/configuration/defaults/backup/Program b/root/etc/e-smith/db/configuration/defaults/backup/Program new file mode 100644 index 0000000..cca15f1 --- /dev/null +++ b/root/etc/e-smith/db/configuration/defaults/backup/Program @@ -0,0 +1 @@ +flexbackup diff --git a/root/etc/e-smith/db/configuration/defaults/backup/backupTime b/root/etc/e-smith/db/configuration/defaults/backup/backupTime new file mode 100644 index 0000000..77ab2b2 --- /dev/null +++ b/root/etc/e-smith/db/configuration/defaults/backup/backupTime @@ -0,0 +1 @@ +2:00 diff --git a/root/etc/e-smith/db/configuration/defaults/backup/reminderTime b/root/etc/e-smith/db/configuration/defaults/backup/reminderTime new file mode 100644 index 0000000..d9fbe93 --- /dev/null +++ b/root/etc/e-smith/db/configuration/defaults/backup/reminderTime @@ -0,0 +1 @@ +14:00 diff --git a/root/etc/e-smith/db/configuration/defaults/backup/status b/root/etc/e-smith/db/configuration/defaults/backup/status new file mode 100644 index 0000000..7a68b11 --- /dev/null +++ b/root/etc/e-smith/db/configuration/defaults/backup/status @@ -0,0 +1 @@ +disabled diff --git a/root/etc/e-smith/db/configuration/defaults/backup/type b/root/etc/e-smith/db/configuration/defaults/backup/type new file mode 100644 index 0000000..24e1098 --- /dev/null +++ b/root/etc/e-smith/db/configuration/defaults/backup/type @@ -0,0 +1 @@ +service diff --git a/root/etc/e-smith/db/configuration/defaults/backupwk/BackupTime b/root/etc/e-smith/db/configuration/defaults/backupwk/BackupTime new file mode 100644 index 0000000..49d1fb9 --- /dev/null +++ b/root/etc/e-smith/db/configuration/defaults/backupwk/BackupTime @@ -0,0 +1 @@ +22:00 diff --git a/root/etc/e-smith/db/configuration/defaults/backupwk/Compression b/root/etc/e-smith/db/configuration/defaults/backupwk/Compression new file mode 100644 index 0000000..1e8b314 --- /dev/null +++ b/root/etc/e-smith/db/configuration/defaults/backupwk/Compression @@ -0,0 +1 @@ +6 diff --git a/root/etc/e-smith/db/configuration/defaults/backupwk/CompressionProg b/root/etc/e-smith/db/configuration/defaults/backupwk/CompressionProg new file mode 100644 index 0000000..d234d64 --- /dev/null +++ b/root/etc/e-smith/db/configuration/defaults/backupwk/CompressionProg @@ -0,0 +1 @@ +gzip diff --git a/root/etc/e-smith/db/configuration/defaults/backupwk/DaysInSet b/root/etc/e-smith/db/configuration/defaults/backupwk/DaysInSet new file mode 100644 index 0000000..d00491f --- /dev/null +++ b/root/etc/e-smith/db/configuration/defaults/backupwk/DaysInSet @@ -0,0 +1 @@ +1 diff --git a/root/etc/e-smith/db/configuration/defaults/backupwk/IncOnlyTimeout b/root/etc/e-smith/db/configuration/defaults/backupwk/IncOnlyTimeout new file mode 100644 index 0000000..7ecb56e --- /dev/null +++ b/root/etc/e-smith/db/configuration/defaults/backupwk/IncOnlyTimeout @@ -0,0 +1 @@ +no diff --git a/root/etc/e-smith/db/configuration/defaults/backupwk/Login b/root/etc/e-smith/db/configuration/defaults/backupwk/Login new file mode 100644 index 0000000..ec76ec2 --- /dev/null +++ b/root/etc/e-smith/db/configuration/defaults/backupwk/Login @@ -0,0 +1 @@ +backup diff --git a/root/etc/e-smith/db/configuration/defaults/backupwk/Password b/root/etc/e-smith/db/configuration/defaults/backupwk/Password new file mode 100644 index 0000000..ec76ec2 --- /dev/null +++ b/root/etc/e-smith/db/configuration/defaults/backupwk/Password @@ -0,0 +1 @@ +backup diff --git a/root/etc/e-smith/db/configuration/defaults/backupwk/Program b/root/etc/e-smith/db/configuration/defaults/backupwk/Program new file mode 100644 index 0000000..288298b --- /dev/null +++ b/root/etc/e-smith/db/configuration/defaults/backupwk/Program @@ -0,0 +1 @@ +dar diff --git a/root/etc/e-smith/db/configuration/defaults/backupwk/SetsMax b/root/etc/e-smith/db/configuration/defaults/backupwk/SetsMax new file mode 100644 index 0000000..d00491f --- /dev/null +++ b/root/etc/e-smith/db/configuration/defaults/backupwk/SetsMax @@ -0,0 +1 @@ +1 diff --git a/root/etc/e-smith/db/configuration/defaults/backupwk/SmbHost b/root/etc/e-smith/db/configuration/defaults/backupwk/SmbHost new file mode 100644 index 0000000..c70dc2d --- /dev/null +++ b/root/etc/e-smith/db/configuration/defaults/backupwk/SmbHost @@ -0,0 +1 @@ +host diff --git a/root/etc/e-smith/db/configuration/defaults/backupwk/SmbShare b/root/etc/e-smith/db/configuration/defaults/backupwk/SmbShare new file mode 100644 index 0000000..75701e4 --- /dev/null +++ b/root/etc/e-smith/db/configuration/defaults/backupwk/SmbShare @@ -0,0 +1 @@ +share diff --git a/root/etc/e-smith/db/configuration/defaults/backupwk/Timeout b/root/etc/e-smith/db/configuration/defaults/backupwk/Timeout new file mode 100644 index 0000000..45a4fb7 --- /dev/null +++ b/root/etc/e-smith/db/configuration/defaults/backupwk/Timeout @@ -0,0 +1 @@ +8 diff --git a/root/etc/e-smith/db/configuration/defaults/backupwk/VFSType b/root/etc/e-smith/db/configuration/defaults/backupwk/VFSType new file mode 100644 index 0000000..fd674ec --- /dev/null +++ b/root/etc/e-smith/db/configuration/defaults/backupwk/VFSType @@ -0,0 +1 @@ +cifs diff --git a/root/etc/e-smith/db/configuration/defaults/backupwk/status b/root/etc/e-smith/db/configuration/defaults/backupwk/status new file mode 100644 index 0000000..7a68b11 --- /dev/null +++ b/root/etc/e-smith/db/configuration/defaults/backupwk/status @@ -0,0 +1 @@ +disabled diff --git a/root/etc/e-smith/db/configuration/defaults/backupwk/type b/root/etc/e-smith/db/configuration/defaults/backupwk/type new file mode 100644 index 0000000..24e1098 --- /dev/null +++ b/root/etc/e-smith/db/configuration/defaults/backupwk/type @@ -0,0 +1 @@ +service diff --git a/root/etc/e-smith/events/actions/delete-index-htm b/root/etc/e-smith/events/actions/delete-index-htm new file mode 100644 index 0000000..9a95e77 --- /dev/null +++ b/root/etc/e-smith/events/actions/delete-index-htm @@ -0,0 +1,2 @@ +#! /bin/sh +exec rm -f /home/e-smith/files/ibays/Primary/html/index.htm diff --git a/root/etc/e-smith/events/actions/eject-tape b/root/etc/e-smith/events/actions/eject-tape new file mode 100644 index 0000000..2cb318d --- /dev/null +++ b/root/etc/e-smith/events/actions/eject-tape @@ -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"); +} diff --git a/root/etc/e-smith/events/actions/merge-system-files b/root/etc/e-smith/events/actions/merge-system-files new file mode 100644 index 0000000..d6126ea --- /dev/null +++ b/root/etc/e-smith/events/actions/merge-system-files @@ -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; diff --git a/root/etc/e-smith/events/actions/reset-restore-idle-flag b/root/etc/e-smith/events/actions/reset-restore-idle-flag new file mode 100644 index 0000000..2f3e381 --- /dev/null +++ b/root/etc/e-smith/events/actions/reset-restore-idle-flag @@ -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); diff --git a/root/etc/e-smith/events/actions/restore-from-disk b/root/etc/e-smith/events/actions/restore-from-disk new file mode 100644 index 0000000..a80ec35 --- /dev/null +++ b/root/etc/e-smith/events/actions/restore-from-disk @@ -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); +} + diff --git a/root/etc/e-smith/events/actions/rewind-tape b/root/etc/e-smith/events/actions/rewind-tape new file mode 100644 index 0000000..107d1fd --- /dev/null +++ b/root/etc/e-smith/events/actions/rewind-tape @@ -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"); diff --git a/root/etc/e-smith/events/actions/save-system-files b/root/etc/e-smith/events/actions/save-system-files new file mode 100644 index 0000000..7ed1f0e --- /dev/null +++ b/root/etc/e-smith/events/actions/save-system-files @@ -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; diff --git a/root/etc/e-smith/events/actions/workstation-backup-dar b/root/etc/e-smith/events/actions/workstation-backup-dar new file mode 100644 index 0000000..72a0098 --- /dev/null +++ b/root/etc/e-smith/events/actions/workstation-backup-dar @@ -0,0 +1,523 @@ +#!/usr/bin/perl -w + +#---------------------------------------------------------------------- +# copyright (C) 2006-2007 Jean-Paul Leclere +# copyright (C) 2007 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 +# +#---------------------------------------------------------------------- + +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($/); }; + }; + $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 () + { + 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 \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; +} diff --git a/root/etc/e-smith/events/post-backup/.gitignore b/root/etc/e-smith/events/post-backup/.gitignore new file mode 100644 index 0000000..e69de29 diff --git a/root/etc/e-smith/events/pre-backup/.gitignore b/root/etc/e-smith/events/pre-backup/.gitignore new file mode 100644 index 0000000..e69de29 diff --git a/root/etc/e-smith/locale/en-us/etc/e-smith/web/functions/backup b/root/etc/e-smith/locale/en-us/etc/e-smith/web/functions/backup new file mode 100644 index 0000000..36592e7 --- /dev/null +++ b/root/etc/e-smith/locale/en-us/etc/e-smith/web/functions/backup @@ -0,0 +1,945 @@ + + + BACKUP_TITLE + Backup or restore server data + + + BACKUP_DESC + + The server provides two ways to back up and restore + your server: using your local desktop or a tape drive.

+ +

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 + $tarsize. 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.

+ +

The tape backup method uses a software package called $module + 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 $dumpsize of data.

+ +

Both restore methods allow you to restore your configuration and user + data files. Ideally, the restore should be performed on a freshly + installed server.

+ ]]> +
+
+ + BACKUP_DESC_DAR + + 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.

+ +

Tape Backup. This method uses a software package called $module + 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 $dumpsize of data.

+ +

Workstation backup. This method uses a software package called dar + 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 $tarsize uncompressed. + Twice the compressed data size must be available on the backup share.

+ +

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 + $tarsize. 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.

+ +

All backup methods allow you to restore your configuration and user + data files. Workstation backup provides individual file restore. Ideally, + full restore should be performed on a freshly installed server.

+ ]]> +
+
+ + BACKUP_CONFIG_STATUS + Backup configuration and status + + + TAPE_BACKUPS_ENABLED + + enabled. + ]]> + + + + BACKUPS_RUN_AT + Regular tape backups will run at: + + + REMINDER_MESSAGE_AT + Reminder messages will be sent at: + + + TAPE_BACKUPS_DISABLED + + disabled + ]]> + + + + DESKTOP_BACKUP + Backup to desktop + + + DESKTOP_RESTORE + Restore from desktop + + + DESKTOP_VERIFY + Verify desktop backup file + + + TAPE_CONFIGURE + Configure tape backup + + + TAPE_RESTORE + Restore from tape + + + RESTORE_IN_PROGRESS_BEGAN_AT + A system restore is in progress. It began at: + + + REFRESH_THIS_DISPLAY + Refresh this display + + + CONFIGURE_TAPE_BACKUP + Configure tape backup + + + RESTORE_COMPLETED + A system restore has completed + + + STARTED_AT + It began at: + + + FINISHED_AT + and finished at: + + + YOU_MUST_REBOOT + + You must reboot the server to activate any configuration changes that were + made as a result of this restore. + + + + REBOOT + Reboot + + + SELECT_AN_ACTION + Select an action + + + X_BACKUP_OR_RESTORE + X Backup or restore server data + + + ERR_PRE_BACKUP + Error occurred during pre-backup actions. + + + ERR_PRE_RESTORE + Error occurred during pre-restore actions. + + + ERR_POST_BACKUP + Error occurred during post-backup actions. + + + RESTORE_SERVER_CONFIG + Restore server configuration + + + DESKTOP_RESTORE_DESC + + The restore should be performed on a freshly installed server. + ]]> + + + + FREE_SPACE + + + + + + MUST_REBOOT_AFTER_RESTORE + After the restore completes you must reboot the server. + + + FILE_TO_RESTORE + Backup file to restore from + + + VERIFY_BACKUP_DESC + + 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.

+ ]]> +
+
+ + SELECT_BACKUP_FILE + Select backup file + + + VERIFY + Verify + + + RESTORE_CANNOT_PROCEED + Unable to proceed with restore of server configuration + + + ANOTHER_RESTORE_IN_PROGRESS + Another restore is in progress. Please try again later. + + + RESTORE_IN_PROGRESS + Restore in progress + + + RESTORE_IN_PROGRESS_DESC + + 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. + + + + FILES_HAVE_BEEN_RESTORED + The following files and directories have been restored: + + + RESTORE_FAILED_MSG + Restore failed! There was an error in reading the backup file. + + + RESTORE_COMPLETE + Restore complete + + + ERR_RESTORING_GID + Error occurred while restoring gid of 'www' + + + ERR_RESTORING_INITIAL_GRP + Error occurred while restoring initial group of 'www'. + + + RESTORE_FAILED + Restore failed! The backup file was incomplete. + + + COULD_NOT_EXEC_PIPELINE + Could not execute backup pipeline: + + + COULD_NOT_DECODE + Could not decode backup file: + + + FILES_IN_BACKUP + The following files are considered in the backup : + + + VERIFY_COMPLETE + Verification is complete + + + BACKUP_FILE_INCOMPLETE + The backup file was incomplete + + + ERR_READING_FILE + There was an error in reading the backup file. + + + ENABLE_DISABLE_TAPE + Enable/Disable Nightly Tape Backup + + + TAPE_CONFIG_DESC + + Select whether you wish to enable nightly backups. Then indicate the + desired times for the backup and the load tape reminder.

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.

+ ]]> +
+
+ + ENABLE_TAPE_BACKUP + Enable tape backup + + + TAPE_BACKUP_TIME + Tape backup time of day (hour/min) + + + LOAD_TAPE_REMINDER_TIME + Load tape reminder time of day (hour/min) + + + AM/PM + AM/PM + + + AM + AM + + + PM + PM + + + UPDATE_CONF + Update + + + UPDATING_TAPE_CONF + Updating tape backup configuration + + + ERR_INVALID_HOUR + Error: invalid backup hour: + + + BETWEEN_0_AND_12 + Please choose an hour between 0 and 12. + + + ERR_INVALID_MINUTE + Error: invalid backup minute: + + + BETWEEN_0_AND_59 + Please choose a minute between 0 and 59. + + + ERR_INVALID_REMINDER_HOUR + Error: invalid reminder hour: + + + ERR_INVALID_REMINDER_MINUTE + Error: invalid reminder minute: + + + ERR_CONF_BACKUP + Error occurred during conf-backup event. + + + SUCCESSFULLY_ENABLED_TAPE + Successfully enabled tape backups + + + WITH_BACKUP_TIME + with backup time: + + + WITH_REMINDER_TIME + and load tape reminder time: + + + SUCCESSFULLY_DISABLED + Successfully disabled tape backups + + + RESTORE_CONF_FROM_TAPE + Restore server configuration from tape backup + + + RESTORE_CONF_FROM_TAPE_DESC + + This process will restore the configuration and user data files from a + server tape backup. The restore should be performed on a freshly installed server.

+

Ensure that you have loaded the desired backup tape into the tape drive + before proceeding.

+

After the restore completes you must reboot the server.

+ ]]> +
+
+ + RESTORE_FROM_TAPE + Restore From Tape + + + UNABLE_TO_RESTORE_CONF + Unable to restore server configuration + + + RESTORING_FROM_TAPE + Restoring From Tape + + + NOW_RESTORING_FROM_TAPE + + Your server configuration and user data + files are now being restored from tape. + + + + ERR_RESTORING_FROM_TAPE + Error occurred restoring files from tape. + + + ERR_UPDATING_CONF_AFTER_TAPE_RESTORE + Error occurred while updating system configuration after tape + restore. + + + + COULD_NOT_FORK + Could not fork: + + + SERVER_REBOOT + Server reboot + + + SERVER_WILL_REBOOT + Your server will now reboot. + + + NO_UID_FOR_NAME + Could not get uid for user named: + + + PAGE_REFRESH_IN + here. + ]]> + + + Backup or restore + Backup or restore + + + + BACKUP_DESKTOP_TOO_BIG + + + Your server has too much data for a reliable backup to desktop. + + ]]> + + + + WORKSTN_BACKUPS_DISABLED + + disabled + ]]> + + + + WORKSTN_BACKUPS_ENABLED + + enabled. + ]]> + + + + WKBACKUPS_RUN_AT + Regular workstation backups will run at: + + + WORKSTN_CONFIGURE + Configure workstation backup + + + WORKSTN_VERIFY + Verify workstation backup + + + WORKSTN_RESTORE + Restore from workstation + + + CONFIGURE_WORKSTN_BACKUP + Configure Workstation Backup + + + ENABLE_DISABLE_WORKSTN + Enable/Disable Daily Workstation Backup + + + ENABLE_WORKSTN_BACKUP + Enable Workstation Backup + + + WORKSTN_BACKUP_TIME + Workstation backup time of day (hour/min) + + + UPDATING_WORKSTN_CONF + Updating workstation backup configuration + + + SUCCESSFULLY_ENABLED_WORKSTN + Successfully enabled workstation backups + + + SUCCESSFULLY_DISABLED_WORKSTN + Successfully disabled workstation backups + + + VERIFY_WORKSTN_BACKUP_FILE + Verify workstation backup + + + VERIFY_WORKSTN_BACKUP_DESC + + 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.You must choose the backup you want to verify

+

Only files flagged with [Saved] are contained in the backup.

+
Backup files are verified from shared folder : + ]]> +
+
+ + RESTORE_CONF_FROM_WORKSTN + Restore server configuration from workstation backup + + + RESTORE_CONF_FROM_WORKSTN_DESC + + This process will restore the configuration and user data files from a + Server workstation backup. The restore + should be performed on a freshly installed Server.

+

Ensure that choose the right backup to restore below + before proceeding.

+

After the restore completes you must reboot the server.

+ Backup will be restored from : + ]]> +
+
+ + RESTORE_FROM_WORKSTN + Restore From Workstation + + + RESTORING_FROM_WORKSTN + Restoring From Workstation + + + NOW_RESTORING_FROM_WORKSTN + + Your server configuration and user data + files are now being restored from workstation shared folder. + + + + ERR_RESTORING_FROM_WORKSTN + Error occurred restoring files from workstation. + + + ERR_UPDATING_CONF_AFTER_WORKSTN_RESTORE + Error occurred while updating system configuration after workstation + restore. + + + + WORKSTN_NAME + Workstation IP or hostname + + + + WORKSTN_BACKUP_SETTINGS + Workstation Backup Settings + + + SHARED_FOLDER_NAME + Backup share + + + + WORKSTN_LOGIN + Login name + + + + WORKSTATION_BACKUP_DEST + Backup workstation settings + + + CONFIGURE_WORKSTN_BACKUP_DESC + 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. + + + ERR_INVALID_WORKSTN + Invalid Workstation IP or Hostname + + + + ERR_INVALID_FOLDER + Invalid share name + + + + ERR_INVALID_LOGIN + Invalid Login + + + + ERR_INVALID_PASSWORD + Invalid Password + + + ERR_ALREADY_MOUNTED + Backup directory is already mounted + + + ERR_MOUNTING_SMBSHARE + Unable to mount workstation shared folder + + + ERR_NOT_MOUNTED + Backup directory is not mounted + + + WORKSTN_NOT_SET + You must first correctly configure your workstation backup + + + NO_BACKUPS_TO_RESTORE + There is no backup set on configured workstation shared folder. Verify your configuration settings. + + + NUMBER_OF_SETS + Number of rotating backup sets + + + NUMBER_OF_FILES_IN_SET + Daily backups in each set + + + ERR_INVALID_SETS_NUMBER + Sets number must be 1 or greater + + + ERR_INVALID_FILES_IN_SET_NUMBER + This number must be 1 or greater. First backup in set is full others are incrementals + + + WORKSTN_TIMEOUT + Optional backup session timeout (hours) + + + INC_ONLY_TIMEOUT + Don't timeout full backup sessions + + + ERR_INVALID_TIMEOUT + Maximum backup time must be set between 1 and 24 hours + + + ERR_NO_HOST_DIR + No directory for your host in shared folder. Maybe your host name is different from backup ones + + + ERROR_READING_FILE + Error while reading files from + + + WORKSTN_SEL_RESTORE + Selective file restore from workstation + + + WORKSTN_SELECTIVE_RESTORE + Workstation selective file restore + + + ALL_BACKUPS + All backups + + + WORKSTN_SEL_REST_DESC + +
+ 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.

+ You have the responsibility not to restore files which could break the + functioning of your server.

Currently, files will be restored from : + ]]> +
+
+ + BACKUP_CHOICE + Selecting files to display + + + SELECT_DATE_BEFORE + Restore most recent before + + + FILTER_EXPRESSION + Names filtered by + + + READ_COMPLETE + + Warning : If you select a directory, + all contained files and directories will be restored.

+ By default the most recent version of selected files is restored, but if you specify a date + in the format [ [ [yyyy/]mm/]dd-]hh:mm[:ss] the process + will restore only the most recent version modified before the given date. + ]]> + + + + ERR_INVALID_SELDATE + 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 + + + SELECT_FILES_TO_RESTORE + Select files to restore + + + ERR_WHILE_UNMOUNTING + Error occurs when unmounting distant share + + + ERR_DAR_CATALOG + Error when using Dar catalog + + + COMPRESSION_LEVEL + Backup compression level [0-9] + + + FULL_ONLY_ON + Full backup is allowed on + + + ERR_INVALID_COMPRESSION + Compression level must be set between 0 (no compression) and 9 (maximum compression) + + + DOW + Sunday Monday Tuesday Wednesday Thursday Friday Saturday Everyday + + + CONFIGURATION_TO_BE_DONE + Please configure the backup settings. + + + WORKSTN_BACKUP_DESC + + This panel displays the present workstation backup configuration. You can + change it in this panel and the next one.

+ ]]> + + + + WORKSTN_BACKUP_NOT_CONFIGURED + + Presently, workstation backup is not configured. You can set this configuration + with this panel and the next one.

+ ]]> + + + + WORKSTN_BACKUP_ENABLED + Backup is + + + WORKSTN_BACKUP_USB + Backup is made on local removable disk + + + WORKSTN_BACKUP_MNT + Backup is made on mounted disk + + + WORKSTN_BACKUP_HOST + Backup is made on LAN workstation + + + WORKSTN_BACKUP_VFSTYPE + via + + + WORKSTN_BACKUP_SHARE + Destination backup share folder is + + + WORKSTN_BACKUP_TOD + Daily backup occurs at + + + LOGIN + Login is + + + PASSWORD + Password is + + + WORKSTN_BACKUP_SETSNUM + Number of rotating backup sets is + + + WORKSTN_BACKUP_DAYSINSET + Number of daily backups contained in each set is + + + WORKSTN_BACKUP_COMPRESSION + Compression level (0-9) of backup is + + + WORKSTN_BACKUP_TIMEOUT + Each daily backup session is cleanly timed out after + + + WORKSTN_BACKUP_INCONLY_TIMEOUT + except full backups which are cleanly timed out after 24 hours + + + WORKSTN_FULL_BACKUP_EVERYDAY + Full backup sessions (new backup set) are allowed everyday + + + WORKSTN_FULL_BACKUP_DAY + Full backup session (new backup sets) is allowed only on + + + WORKSTATION_BACKUP_SETCONF + Create or modify workstation backup configuration + + + SELECT_VFS_TYPE + Select the type of share for backup destination + + + ERR_NO_USB_DISK + Error : No removable disk available. Please connect a removable disk or select another type of workstation backup. + + + ERR_NO_MOUNTED_DISK + Error : No mounted disk available. Please mount a disk or select another type of workstation backup. + + + HOURS + hours. + + + ERR_NO_FULL_BACKUP + Aborting restore because needed full backup is missing or unreadable. + + + ERR_NO_INC_BACKUP + Aborting restore because the set has missing or unreadable incremental backup number + + + CHECK_TO_VERIFY_FULL_RESTORE + Check here to test integrity of all backups needed for a full restore with the selected backup + + + TESTING_NEEDED_BACKUPS_FOR_RESTORE + Testing all backups needed for a full restore with selected backup + + + TESTED_BACKUP + Testing integrity of backup + + + RESTORE_VERIFY_FAILED + Verify integrity failed + + + CHECK_INTEGRITY_WARNING + Warning : For large backups, checking integrity may be a long task and should be made with daily workstation backup disabled. + + + cifs + cifs + + + nfs + nfs + + + local removable disk + Local removable disk + + + Mounted disk + Mounted disk + + + ERROR_WHEN_TESTING_REMOTE_SERVER + The parameters have been saved, however the remote host is not reachable, please check your settings. + + + DO_NOT_RESTORE_BIN_SBIN_LIB_LIB64_FROM_SME9 + 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. + + + SMBV1 + Mount as legacy SMB v1 share (unsecure, not recommended). + + + + diff --git a/root/etc/e-smith/templates.metadata/etc/dar/CIFScredentials b/root/etc/e-smith/templates.metadata/etc/dar/CIFScredentials new file mode 100644 index 0000000..d102826 --- /dev/null +++ b/root/etc/e-smith/templates.metadata/etc/dar/CIFScredentials @@ -0,0 +1 @@ +PERMS=0600 diff --git a/root/etc/e-smith/templates/etc/crontab/backup b/root/etc/e-smith/templates/etc/crontab/backup new file mode 100644 index 0000000..7180488 --- /dev/null +++ b/root/etc/e-smith/templates/etc/crontab/backup @@ -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" +} diff --git a/root/etc/e-smith/templates/etc/crontab/backupwk b/root/etc/e-smith/templates/etc/crontab/backupwk new file mode 100644 index 0000000..6179fed --- /dev/null +++ b/root/etc/e-smith/templates/etc/crontab/backupwk @@ -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"; + } +} diff --git a/root/etc/e-smith/templates/etc/dar/CIFScredentials/template-begin b/root/etc/e-smith/templates/etc/dar/CIFScredentials/template-begin new file mode 100644 index 0000000..b65f1bc --- /dev/null +++ b/root/etc/e-smith/templates/etc/dar/CIFScredentials/template-begin @@ -0,0 +1,2 @@ +username={$backupwk{'Login'}} +password={$backupwk{'Password'}} diff --git a/root/etc/e-smith/templates/etc/dar/DailyBackup.dcf/10compression b/root/etc/e-smith/templates/etc/dar/DailyBackup.dcf/10compression new file mode 100644 index 0000000..c4c625f --- /dev/null +++ b/root/etc/e-smith/templates/etc/dar/DailyBackup.dcf/10compression @@ -0,0 +1,6 @@ +{ + $level = $backupwk{Compression} || 0; + $prog = $backupwk{CompressionProg} || 'gzip'; + + $OUT = ($level eq '0' or $prog eq 'none') ? "#Compression off" : "--$prog=$level" +} diff --git a/root/etc/e-smith/templates/etc/dar/DailyBackup.dcf/20empty-dir b/root/etc/e-smith/templates/etc/dar/DailyBackup.dcf/20empty-dir new file mode 100644 index 0000000..b0ffb24 --- /dev/null +++ b/root/etc/e-smith/templates/etc/dar/DailyBackup.dcf/20empty-dir @@ -0,0 +1 @@ +--empty-dir diff --git a/root/etc/e-smith/templates/etc/dar/DailyBackup.dcf/30fs-root b/root/etc/e-smith/templates/etc/dar/DailyBackup.dcf/30fs-root new file mode 100644 index 0000000..888b94c --- /dev/null +++ b/root/etc/e-smith/templates/etc/dar/DailyBackup.dcf/30fs-root @@ -0,0 +1 @@ +--fs-root / diff --git a/root/etc/e-smith/templates/etc/dar/DailyBackup.dcf/40go-into b/root/etc/e-smith/templates/etc/dar/DailyBackup.dcf/40go-into new file mode 100644 index 0000000..beb984a --- /dev/null +++ b/root/etc/e-smith/templates/etc/dar/DailyBackup.dcf/40go-into @@ -0,0 +1,8 @@ +{ + use esmith::Backup; + + my @backup_list = esmith::Backup->restore_list; + foreach my $dir ( @backup_list ) { + $OUT .= "--go-into $dir\n"; + } +} diff --git a/root/etc/e-smith/templates/etc/dar/DailyBackup.dcf/45prune b/root/etc/e-smith/templates/etc/dar/DailyBackup.dcf/45prune new file mode 100644 index 0000000..4aa04e2 --- /dev/null +++ b/root/etc/e-smith/templates/etc/dar/DailyBackup.dcf/45prune @@ -0,0 +1,7 @@ +{ + use esmith::Backup; + my @exclusion_list = esmith::Backup->excludes; + foreach my $dir ( @exclusion_list ) { + $OUT .= "--prune $dir\n"; + } +} diff --git a/root/etc/e-smith/templates/etc/dar/DailyBackup.dcf/50exclude b/root/etc/e-smith/templates/etc/dar/DailyBackup.dcf/50exclude new file mode 100644 index 0000000..e69de29 diff --git a/root/etc/e-smith/templates/etc/dar/DailyBackup.dcf/60exclude-compression b/root/etc/e-smith/templates/etc/dar/DailyBackup.dcf/60exclude-compression new file mode 100644 index 0000000..dcfa416 --- /dev/null +++ b/root/etc/e-smith/templates/etc/dar/DailyBackup.dcf/60exclude-compression @@ -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"' +} diff --git a/root/etc/e-smith/templates/etc/dar/DailyBackup.dcf/70noconf b/root/etc/e-smith/templates/etc/dar/DailyBackup.dcf/70noconf new file mode 100644 index 0000000..635324d --- /dev/null +++ b/root/etc/e-smith/templates/etc/dar/DailyBackup.dcf/70noconf @@ -0,0 +1 @@ +--noconf diff --git a/root/etc/e-smith/templates/etc/dar/DailyBackup.dcf/80no-warn b/root/etc/e-smith/templates/etc/dar/DailyBackup.dcf/80no-warn new file mode 100644 index 0000000..c9cd60b --- /dev/null +++ b/root/etc/e-smith/templates/etc/dar/DailyBackup.dcf/80no-warn @@ -0,0 +1 @@ +--no-warn diff --git a/root/etc/e-smith/templates/etc/dar/DailyBackup.dcf/90slice b/root/etc/e-smith/templates/etc/dar/DailyBackup.dcf/90slice new file mode 100644 index 0000000..5b12218 --- /dev/null +++ b/root/etc/e-smith/templates/etc/dar/DailyBackup.dcf/90slice @@ -0,0 +1,3 @@ +{ +($backupwk{Slice} || '700M') eq '700M' ? "--slice 700M\n" : "--slice $backupwk{Slice}\n" +} diff --git a/root/etc/e-smith/templates/etc/httpd/conf/httpd.conf/97backupProxyEnv b/root/etc/e-smith/templates/etc/httpd/conf/httpd.conf/97backupProxyEnv new file mode 100644 index 0000000..a93f6d7 --- /dev/null +++ b/root/etc/e-smith/templates/etc/httpd/conf/httpd.conf/97backupProxyEnv @@ -0,0 +1,4 @@ + + SetEnv force-proxy-request-1.0 1 + + diff --git a/root/etc/e-smith/tests/10e-smith-backup/backuphistory.conf b/root/etc/e-smith/tests/10e-smith-backup/backuphistory.conf new file mode 100644 index 0000000..a8c7794 --- /dev/null +++ b/root/etc/e-smith/tests/10e-smith-backup/backuphistory.conf @@ -0,0 +1 @@ +1053551285=backup_record|BackupType|desktop|StartEpochTime|1053551285|EndEpochTime|1053551299|Result|0 diff --git a/root/etc/e-smith/tests/10e-smith-backup/group-installed b/root/etc/e-smith/tests/10e-smith-backup/group-installed new file mode 100644 index 0000000..0b6b73f --- /dev/null +++ b/root/etc/e-smith/tests/10e-smith-backup/group-installed @@ -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: diff --git a/root/etc/e-smith/tests/10e-smith-backup/group-merged b/root/etc/e-smith/tests/10e-smith-backup/group-merged new file mode 100644 index 0000000..4b67aad --- /dev/null +++ b/root/etc/e-smith/tests/10e-smith-backup/group-merged @@ -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: diff --git a/root/etc/e-smith/tests/10e-smith-backup/group-restored b/root/etc/e-smith/tests/10e-smith-backup/group-restored new file mode 100644 index 0000000..0acad2a --- /dev/null +++ b/root/etc/e-smith/tests/10e-smith-backup/group-restored @@ -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: diff --git a/root/etc/e-smith/tests/10e-smith-backup/passwd-installed b/root/etc/e-smith/tests/10e-smith-backup/passwd-installed new file mode 100644 index 0000000..57d5af3 --- /dev/null +++ b/root/etc/e-smith/tests/10e-smith-backup/passwd-installed @@ -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 diff --git a/root/etc/e-smith/tests/10e-smith-backup/passwd-merged b/root/etc/e-smith/tests/10e-smith-backup/passwd-merged new file mode 100644 index 0000000..526f661 --- /dev/null +++ b/root/etc/e-smith/tests/10e-smith-backup/passwd-merged @@ -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 diff --git a/root/etc/e-smith/tests/10e-smith-backup/passwd-restored b/root/etc/e-smith/tests/10e-smith-backup/passwd-restored new file mode 100644 index 0000000..e6bc299 --- /dev/null +++ b/root/etc/e-smith/tests/10e-smith-backup/passwd-restored @@ -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 diff --git a/root/etc/e-smith/web/functions/backup b/root/etc/e-smith/web/functions/backup new file mode 100644 index 0000000..4e21c31 --- /dev/null +++ b/root/etc/e-smith/web/functions/backup @@ -0,0 +1,3297 @@ +#!/usr/bin/perl -wT +#---------------------------------------------------------------------- +# heading : Administration +# description : Backup or restore +# navigation : 4000 4200 +# 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::FormMagick; +use esmith::ConfigDB; +use esmith::Backup; +use esmith::BackupHistoryDB; +use esmith::BlockDevices; +use esmith::AccountsDB; +use esmith::cgi; +use esmith::util; +use esmith::lockfile; +use File::Find; +use File::Path qw(make_path remove_tree); + +$File::Find::dont_use_nlink = 1; # fix for Windows shares + +my $fm = esmith::FormMagick->new(); + +# These statements _must_ come _after_ the FormMagick constructor. It sets +# POST_MAX and DISABLE_UPLOADS to values that will cause this script to fail +# on restores and verification of files. +$CGI::POST_MAX = -1; # allow any size POST +$CGI::DISABLE_UPLOADS = 0; # need to upload to restore from desktop + +$fm->parse_xml(); + +my $conf = esmith::ConfigDB->open() + || die $fm->localise('CANNOT_OPEN').'configuration db'; + +my $restore = esmith::ConfigDB->open('/etc/e-smith/restore') + || die $fm->localise('CANNOT_OPEN').'/etc/e-smith/restore'; + +my $es_backup = new esmith::Backup or die "Couldn't create Backup object\n"; + +my @directories = $es_backup->restore_list; +@directories = grep { -e "/$_" } @directories; + +my @backup_excludes = $es_backup->excludes; + +# Unbuffer standard output so that files and directories are listed as +# they are restored +$| = 1; + +# Store away current gid of 'www' group. +my $www_gid = getgrnam("www"); + +#------------------------------------------------------------ +# examine state parameter and display the appropriate form +#------------------------------------------------------------ + +my $q = $fm->{cgi}; + +if (! grep (/^state$/, $q->param)) +{ + showInitial ($q, ''); +} +elsif ($q->param ('state') eq "perform") +{ + performAndShowResult ($q); +} +elsif ($q->param ('state') eq "tape-configure") +{ + updateTapeBackupConfig($q); +} +elsif ($q->param ('state') eq "tape-restore") +{ + performTapeRestore ($q); +} +elsif ($q->param ('state') eq "workstn-configure") +{ + WorkstnBackupConfig1($q); +} +elsif ($q->param ('state') eq "workstn-configure1") +{ + updateWorkstnBackupConfig($q); +} +elsif ($q->param ('state') eq "workstn-verify") +{ + performWorkstnVerify($q); +} +elsif ($q->param ('state') eq "workstn-restore") +{ + performWorkstnRestore ($q); +} +elsif ($q->param ('state') eq "workstn-sel-restore") +{ + performWorkstnSelRestore ($q); +} +elsif ($q->param ('state') eq "workstn-sel-restore2") +{ + performWorkstnSelRestore2 ($q); +} +else +{ + esmith::cgi::genStateError ($q, undef); +} + +exit (0); + +#------------------------------------------------------------ +# subroutine to display initial form +#------------------------------------------------------------ + +sub showInitial +{ + my ($q, $msg) = @_; + + my $rec = $restore->get('restore'); + if($msg eq '') + { + if($rec) + { + $msg = $rec->prop('errmsg') || ''; + $rec->delete_prop('errmsg'); + } + } + + if ($msg eq '') + { + esmith::cgi::genHeaderNonCacheable ($q, undef, + $fm->localise('BACKUP_TITLE')); + } + else + { + esmith::cgi::genHeaderNonCacheable + ($q, undef, $fm->localise('OPERATION_STATUS_REPORT')); + + print $q->div ({-class => "sme-error"}, $msg); + print $q->hr; + } + print $q->div({-class => 'error'}, + $q->h5('Warning: a reboot is required before proceeding! + Failure to reboot now may leave your system in an unknown + state!')) + if $conf->get_prop('bootstrap-console', 'Run') eq 'yes'; + + my ($tarsize, $dumpsize, undef, undef) = &CalculateSizes(); + + my $module = $conf->get('backup'); + if ($module) + { + $module = $module->prop('Program'); + } + + # The default e-smith backup program is flexbackup. + + unless (defined $module) + { + $module = "flexbackup"; + } + elsif ($module eq '') + { + $module = "flexbackup"; + } + + # Hack to evaluate embedded vars + print eval 'return "'.$fm->localise('BACKUP_DESC_DAR').'\n";'; + + if ($tarsize =~ /Tb/ or $tarsize =~ /(\d+)Gb/ and $1 >= 2) + { + print $fm->localise("BACKUP_DESKTOP_TOO_BIG"), "\n"; + } + + print $q->h2($fm->localise("BACKUP_CONFIG_STATUS")),"\n"; + + my $backup_status = $conf->get('backup'); + if ($backup_status) + { + $backup_status = $backup_status->prop('status'); + } + + if (defined $backup_status && $backup_status eq "enabled") + { + my $backupTime = $conf->get('backup')->prop('backupTime'); + my $reminderTime = $conf->get('backup')->prop('reminderTime'); + + print $q->p ($fm->localise('TAPE_BACKUPS_ENABLED'), + $fm->localise('BACKUPS_RUN_AT'),$q->b($backupTime), + $fm->localise('REMINDER_MESSAGE_AT'),$q->b($reminderTime)), + "\n"; + } + else + { + print $q->p($fm->localise('TAPE_BACKUPS_DISABLED')),"\n"; + } + + my $backupwk_status = $conf->get('backupwk'); + if ($backupwk_status) + { + $backupwk_status = $backupwk_status->prop('status'); + } + + if (defined $backupwk_status && $backupwk_status eq "enabled") + { + my $backupwkTime = $conf->get('backupwk')->prop('BackupTime'); + + print $q->p ($fm->localise('WORKSTN_BACKUPS_ENABLED'), + $fm->localise('WKBACKUPS_RUN_AT'),$q->b($backupwkTime)); + } + else + { + print $q->p($fm->localise('WORKSTN_BACKUPS_DISABLED')); + } + + my %labels = ( + "desktop-backup" => $fm->localise('DESKTOP_BACKUP'), + "tape-configure" => $fm->localise('TAPE_CONFIGURE'), + "tape-restore" => $fm->localise('TAPE_RESTORE'), + "workstn-configure" => $fm->localise('WORKSTN_CONFIGURE'), + "workstn-verify" => $fm->localise('WORKSTN_VERIFY'), + "workstn-restore" => $fm->localise('WORKSTN_RESTORE'), + "workstn-sel-restore" => $fm->localise('WORKSTN_SEL_RESTORE'), + ); + + my @labels = ( + 'desktop-backup', + 'tape-configure', + 'tape-restore', + 'workstn-configure', + 'workstn-verify', + 'workstn-restore', + 'workstn-sel-restore', + ); + + my $default_action = 'desktop-backup'; + + my $restore_state; + if($rec) + { + $restore_state = $rec->prop('state'); + } + + unless (defined $restore_state) + { + # Undefined, set it to idle + if ($rec) + { + $rec->reset_props(type=>'status', state=>'idle', finish=>0, + start=>0); + } + else + { + $rec = $restore->new_record('restore', + {type=>'status', state=>'idle', finish=>0, start=>0}); + } + $restore_state = 'idle'; + } + elsif ($restore_state eq 'running') + { + my $start = $rec->prop('start'); + $start = scalar localtime($start); + + print $q->p ($fm->localise('RESTORE_IN_PROGRESS_BEGAN_AT') + . "$start.\n" ); + + %labels = ( + "refresh" => $fm->localise('REFRESH_THIS_DISPLAY'), + "tape-configure" => $fm->localise('CONFIGURE_TAPE_BACKUP'), + "workstn-configure" => $fm->localise('CONFIGURE_WORKSTN_BACKUP'), + ); + + @labels = ( + 'refresh', + 'tape-configure', + 'workstn-configure', + ); + + $default_action = 'refresh'; + } + elsif ($restore_state eq 'complete') + { + my $start = $rec->prop('start'); + $start = scalar localtime($start); + my $finish = $rec->prop('finish'); + $finish = scalar localtime($finish); + + print $q->p ($fm->localise('RESTORE_COMPLETED'),$q->br(), + $fm->localise('STARTED_AT'),$q->b($start),$q->br(), + $fm->localise('FINISHED_AT'),$q->b($finish)),"\n"; + + print $q->p ( + $q->b ($fm->localise('YOU_MUST_REBOOT') + ) + ),"\n"; + + $default_action = 'reboot'; + } + else + { + # Unknown state. Reset it to idle + + $rec->set_prop('state', 'idle'); + $restore_state = 'idle'; + } + + print $q->startform( + -method => 'POST', + -action => $q->url (-absolute => 1) + ),"\n"; + + print $q->start_table ({-class => "sme-noborders"}),"\n"; + + if ($default_action eq 'reboot') + { + print $q->start_table ({width => "100%", -class => "sme-noborders"}),"\n"; + print esmith::cgi::genButtonRow( + $q, + $q->submit (-name => 'action', -value => + $fm->localise('REBOOT')) + ); + # Put in a hidden widget to store the reboot value. + print $q->hidden( + -name => 'function', + -value => 'reboot' + ),"\n"; + print $q->end_table,"\n"; + } + else + { + print $q->Tr( + $q->td({-class => "sme-noborders-label"}, + $fm->localise("SELECT_AN_ACTION")), + $q->td({-class => "sme-noborders-content"}, + $q->popup_menu ( + -name => 'function', + -values => [ @labels ], + -default => $default_action, + -labels => \%labels + ) + ) + ),"\n"; + + } + + print $q->end_table,"\n"; + + if ($default_action ne 'reboot') + { + print $q->start_table ({width => "100%", -class => "sme-noborders"}), + "\n"; + + print esmith::cgi::genButtonRow( + $q, + $q->submit (-name => 'action', -value => + $fm->localise('PERFORM')) + ); + + print $q->end_table,"\n"; + } + + print $q->hidden ( + -name => 'state', + -override => 1, + -default => 'perform' + ),"\n"; + + print $q->endform,"\n"; + + esmith::cgi::genFooter($fm); + + return; +} + +sub performAndShowResult +{ + my ($q) = @_; + + my $function = $q->param ('function'); + + if ($function eq 'refresh') + { + showInitial ($q, ''); + } + elsif ($function eq 'reboot') + { + performReboot(); + } + elsif ($function eq 'desktop-backup') + { + desktopBackup(); + } + elsif ($function eq 'tape-configure') + { + TapeBackupConfig ($q); + } + elsif ($function eq 'tape-restore') + { + tapeRestore(); + } + elsif ($function eq 'workstn-configure') + { + WorkstnBackupConfig ($q); + } + elsif ($function eq 'workstn-verify') + { + workstnVerify(); + } + elsif ($function eq 'workstn-restore') + { + workstnRestore(); + } + elsif ($function eq 'workstn-sel-restore') + { + workstnSelRestore(); + } + else + { + # Unknown function - refresh the screen anyway + showInitial ($q, 'unknown'); + } + + return; + + esmith::cgi::genHeaderNonCacheable ($q, undef, + $fm->localise("X_BACKUP_OR_RESTORE")); + print $q->p ( $function ); + esmith::cgi::genFooter($fm); +} + +sub desktopBackupRecordStatus +{ + my ($backup, $phase, $status) = @_; + my $now = time(); + + warn("Backup terminated: $phase failed - status: $status\n"); + $backup->set_prop('EndEpochTime', "$now"); + $backup->set_prop('Result', "$phase:$status"); +} + +sub desktopBackup () +{ + # Generate a header that will trigger a download and send data as + # an octet stream. + + my $backups = esmith::BackupHistoryDB->open; + my $now = time(); + my $backup_rec = $backups->new_record($now, { + type => 'backup_record', + BackupType => 'desktop', + StartEpochTime => $now, + }); + my $CompressionLevel = $conf->get_prop("backupconsole", "CompressionLevel") || "-6"; + my @exclude = map (" --exclude=$_",@backup_excludes); + + # Dump the current mysql tables so that they are part of the image. + # The events handle cases where mysqld is not enabled, and/or is + # not running. + + my $status = system("/sbin/e-smith/signal-event", "pre-backup", "desktop"); + if ($status) + { + desktopBackupRecordStatus($backup_rec, 'pre-backup', $status); + esmith::cgi::genHeaderNonCacheable( + $fm->{cgi}, + undef, $fm->localise('OPERATION_STATUS_REPORT')); + esmith::cgi::genResult( + $fm->{cgi}, $fm->localise('ERR_PRE_BACKUP')); + return; + } + + print "Expires: 0\n"; + print "Content-type: application/octet-stream\n"; + print "Content-disposition: attachment; filename=smeserver.tgz\n"; + print "\n"; + setpgrp; + my $ourpgrp = getpgrp; + local $SIG{PIPE} = sub + { + local $SIG{HUP} = 'IGNORE'; + warn "Got sigpipe - sending HUP to $ourpgrp\n"; + kill HUP => -$ourpgrp; + desktopBackupRecordStatus($backup_rec, + 'send2browser', 'Incomplete'); + exit 1; + }; + + open(RD, + "/bin/tar --directory / --create @directories --file=-" + . "@exclude | /usr/bin/gzip $CompressionLevel |" + ); + + while () + { + print; + } + + close RD; + + # Remove the dumped tables. + + $status = system("/sbin/e-smith/signal-event", "post-backup", "desktop"); + if ($status) + { + desktopBackupRecordStatus($backup_rec, 'post-backup', $status); + die ($fm->localise('ERR_POST_BACKUP'),"\n"); + } + $now = time(); + $backup_rec->set_prop('EndEpochTime', "$now"); + $backup_rec->set_prop('Result', "0"); +} + +sub TapeBackupConfig +{ + my ($q) = @_; + my $enabledChk = ""; + my $backupAMPM = 'AM'; + my $backupMin; + my $backupHour; + my $reminderAMPM = 'AM'; + my $reminderMin; + my $reminderHour; + + esmith::cgi::genHeaderNonCacheable( + $q, undef, $fm->localise('ENABLE_DISABLE_TAPE')); + + print $q->p ($fm->localise('TAPE_CONFIG_DESC')); + + # Obtain time for backup from the backup cron template + my $rec = $conf->get('backup'); + my $backupTime = "2:00"; + if ($rec) + { + $backupTime = $rec->prop('backupTime') || "2:00"; + } + + ($backupHour, $backupMin) = split (":", $backupTime, -1); + + if ($backupHour > 11) + { + if ($backupHour > 12) + { + $backupHour -= 12; + } + $backupAMPM = 'PM'; + } + + # Obtain time for reminder notice from the backup cron template + my $reminderTime = "14:00"; + if ($rec) + { + $reminderTime = $rec->prop('reminderTime') || "14:00"; + } + + ($reminderHour, $reminderMin) = split (":", $reminderTime, -1); + + if ($reminderHour > 12) + { + $reminderHour -= 12; + $reminderAMPM = 'PM'; + } + + print $q->startform( + -method => 'POST', + -action => $q->url (-absolute => 1) + ); + + print $q->start_table ({-class => "sme-noborders"}); + + my $backup_status; + if ($rec) + { + $backup_status = $rec->prop('status'); + } + + if (defined $backup_status && $backup_status eq "enabled") + { + $enabledChk = "checked"; + } + + print $q->Tr( + $q->td( + $fm->localise('ENABLE_TAPE_BACKUP') + . " " + ) + ); + + print $q->Tr( + esmith::cgi::genCell( + $q,$fm->localise('TAPE_BACKUP_TIME') + ), + + esmith::cgi::genCell ($q, $q->textfield (-name => 'backupHour', + -override => 1, + -default => $backupHour, + -size => 2)), + + esmith::cgi::genCell ($q, $q->textfield (-name => 'backupMin', + -override => 1, + -default => $backupMin, + -size => 2)), + + esmith::cgi::genCell ($q, "AM/PM:"), + + esmith::cgi::genCell ($q, $q->popup_menu (-name => 'backupAMPM', + -values => ['AM', 'PM'], + -default => $backupAMPM))); + + my %timelabels=('AM' => $fm->localise('AM'),'PM' => $fm->localise('PM')); + print $q->Tr( + esmith::cgi::genCell( + $q, $fm->localise('LOAD_TAPE_REMINDER_TIME') + ), + + esmith::cgi::genCell( + $q, + $q->textfield( + -name => 'reminderHour', + -override => 1, + -default => $reminderHour, + -size => 2 + ) + ), + + esmith::cgi::genCell( + $q, + $q->textfield( + -name => 'reminderMin', + -override => 1, + -default => $reminderMin, + -size => 2 + ) + ), + + esmith::cgi::genCell($q, $fm->localise("AM/PM").":"), + + esmith::cgi::genCell( + $q, + $q->popup_menu( + -name => 'reminderAMPM', + -values => ['AM', 'PM'], + -labels => \%timelabels, + -default => $reminderAMPM + ) + ) + ); + + print "\n"; + print $q->start_table ({width => "100%", -class => "sme-noborders"}); + print $q->Tr($q->th({-class => "sme-layout"}, + $q->submit( + -name => 'action', + -value => $fm->localise('UPDATE_CONF') + ) + ) + ); + + print $q->hidden( + -name => 'state', + -override => 1, + -default => 'tape-configure' + ); + + print $q->endform; + print ''; + + esmith::cgi::genFooter($fm); + return; +} + +sub updateTapeBackupConfig +{ + my ($q) = @_; + + my $status = $q->param ('tapebackup'); + my $ampm; + + esmith::cgi::genHeaderNonCacheable( + $q, + undef, $fm->localise('UPDATING_TAPE_CONF') + ); + + if (defined $status && $status eq "on") + { + + #-------------------------------------------------- + # Untaint parameters and check for validity + #-------------------------------------------------- + + my $backupHour = $q->param ('backupHour'); + if ($backupHour =~ /^(.*)$/) { + $backupHour = $1; + } else { + $backupHour = "12"; + } + if (($backupHour < 1) || ($backupHour > 12)) + { + esmith::cgi::genResult( + $fm->{cgi}, $fm->localise('ERR_INVALID_HOUR').$backupHour. + $fm->localise('BETWEEN_1_AND_12') + ); + + return; + } + + my $backupMin = $q->param ('backupMin'); + if ($backupMin =~ /^(.*)$/) { + $backupMin = $1; + } else { + $backupMin = "0"; + } + if (($backupMin < 0) || ($backupMin > 59)) + { + esmith::cgi::genResult( + $fm->{cgi}, $fm->localise('ERR_INVALID_MINUTE').$backupMin. + $fm->localise('BETWEEN_0_AND_59') + ); + + return; + } + + $backupMin = sprintf("%02d", $backupMin); + + $ampm = $q->param ('backupAMPM'); + if ($ampm =~ /^(.*)$/) { + $ampm = $1; + } else { + $ampm = "AM"; + } + + # convert to 24 hour time + + $backupHour = $backupHour % 12; + if ($ampm eq "PM") + { + $backupHour = $backupHour + 12; + } + + my $reminderHour = $q->param ('reminderHour'); + if ($reminderHour =~ /^(.*)$/) { + $reminderHour = $1; + } else { + $reminderHour = "12"; + } + if (($reminderHour < 1) || ($reminderHour > 12)) + { + esmith::cgi::genResult( + $fm->{cgi}, + $fm->localise('ERR_INVALID_REMINDER_HOUR').$reminderHour + .$fm->localise('BETWEEN_1_AND_12') + ); + + return; + } + + my $reminderMin = $q->param ('reminderMin'); + if ($reminderMin =~ /^(.*)$/) { + $reminderMin = $1; + } else { + $reminderMin = "0"; + } + if (($reminderMin < 0) || ($reminderMin > 59)) + { + esmith::cgi::genResult( + $fm->{cgi}, $fm->localise('ERR_INVALID_REMINDER_MINUTE'). + $reminderMin.$fm->localise('BETWEEN_0_AND_59') + ); + return; + } + + $reminderMin = sprintf("%02d", $reminderMin); + + $ampm = $q->param ('reminderAMPM'); + if ($ampm =~ /^(.*)$/) { + $ampm = $1; + } else { + $ampm = "AM"; + } + + # convert to 24 hour time + + $reminderHour = $reminderHour % 12; + if ($ampm eq "PM") + { + $reminderHour = $reminderHour + 12; + } + + # variables passed validity checks, set configuration database values + my $old = $conf->get('UnsavedChanges')->value; + + my $rec = $conf->get('backup'); + unless (defined $rec) + { + $rec = $conf->new_record('backup', {type=>'service'}); + } + + $rec->set_prop('status', 'enabled'); + + my $module = $rec->prop('Program'); + + # The default e-smith backup program is flexbackup. + + unless (defined $module) + { + $module = "flexbackup"; + } + elsif ($module eq '') + { + $module = "flexbackup"; + } + + $rec->set_prop('Program', $module); + $rec->set_prop('backupTime', "$backupHour:$backupMin"); + $rec->set_prop('reminderTime', "$reminderHour:$reminderMin"); + + $conf->get('UnsavedChanges')->set_value($old); + + system("/sbin/e-smith/signal-event", "conf-backup") == 0 + or die($fm->localise('ERR_CONF_BACKUP'),"\n"); + + esmith::cgi::genResult( + $fm->{cgi}, $fm->localise('SUCCESSFULLY_ENABLED_TAPE').$q->br(). + $fm->localise('WITH_BACKUP_TIME')."$backupHour:$backupMin". + $q->br().$fm->localise('WITH_REMINDER_TIME'). + "$reminderHour:$reminderMin"); + } + else + { + # set service to disabled + my $old = $conf->get('UnsavedChanges')->value; + + my $rec = $conf->get('backup'); + unless ($rec) + { + $rec = $conf->new_record('backup', {type=>'service'}); + } + + $rec->set_prop('status', 'disabled'); + $conf->get('UnsavedChanges')->set_value($old); + + system("/sbin/e-smith/signal-event", "conf-backup") == 0 + or die($fm->localise('ERR_CONF_BACKUP')."\n"); + + esmith::cgi::genResult( + $fm->{cgi}, $fm->localise('SUCCESSFULLY_DISABLED') + ); + } + + return; +} + +sub tapeRestore () +{ + esmith::cgi::genHeaderNonCacheable( + $q, undef, $fm->localise('RESTORE_CONF_FROM_TAPE')); + + print $fm->localise('RESTORE_CONF_FROM_TAPE_DESC'); + + print $q->start_multipart_form( + -method => 'POST', + -action => $q->url (-absolute => 1) + ); + + print $q->start_table ({width => "100%", -class => "sme-noborders"}); + + print esmith::cgi::genButtonRow( + $q, + $q->submit (-name => 'action', + -value => $fm->localise('RESTORE_FROM_TAPE')) + ); + print "\n"; + print $q->hidden( + -name => 'state', + -override => 1, + -default => 'tape-restore' + ); + + print $q->endform; + esmith::cgi::genFooter($fm); +} + +sub performTapeRestore +{ + my ($q) = @_; + + #---------------------------------------- + # restore system from backup tape + #---------------------------------------- + + my $lock_file = "/var/lock/subsys/e-smith-restore"; + my $file_handle = &esmith::lockfile::LockFileOrReturn($lock_file); + + unless ($file_handle) + { + esmith::cgi::genHeaderNonCacheable( + $q, + undef, + $fm->localise('UNABLE_TO_RESTORE_CONF') + ); + + print $q->p ( + $q->b ($fm->localise('ANOTHER_RESTORE_IN_PROGRESS') + ) + ); + + esmith::cgi::genFooter($fm); + return; + } + + my $rec = $restore->get('restore'); + $rec->set_prop('state', 'running'); + $rec->set_prop('start', time); + + my $sec = 10; + print "Refresh: $sec; URL=/server-manager/cgi-bin/backup\n"; + esmith::cgi::genHeaderNonCacheable( + $q, undef, $fm->localise() + ); + + print $q->p($fm->localise('NOW_RESTORING_FROM_TAPE') + ); + + print $q->p ( + $q->b ($fm->localise('MUST_REBOOT_AFTER_RESTORE')) + ); + + print $q->p($fm->localise('PAGE_REFRESH_IN', {sec=>$sec})); + + my $child; + + if ($child = fork) + { + # Parent + + $SIG{'CHLD'} = 'IGNORE'; + &esmith::lockfile::UnlockFile($file_handle); + + esmith::cgi::genFooter($fm); + return; + } + elsif (defined $child) + { + # Child + + # Re-establish the lock. Wait till it is relinquished by the parent. + + $file_handle = &esmith::lockfile::LockFileOrWait($lock_file); + + # Close STDOUT so that the web server connection is closed. + + close STDOUT; + + # Now reopen STDOUT for the child. Redirect it to STDERR. + + open(STDOUT, ">&STDERR"); + + unless(system("/sbin/e-smith/signal-event", "pre-restore") == 0) + { + $rec->set_prop('errmsg', $fm->localise('ERR_PRE_RESTORE')); + $rec->delete_prop('state'); + die ($fm->localise('ERR_PRE_RESTORE'),"\n"); + } + unless(system("/sbin/e-smith/signal-event", "restore-tape") == 0) + { + $rec->set_prop('errmsg', $fm->localise('ERR_RESTORING_FROM_TAPE')); + $rec->delete_prop('state'); + die ($fm->localise('ERR_RESTORING_FROM_TAPE')."\n"); + } + + #---------------------------------------- + # regenerate configuration files + #---------------------------------------- + + unless(system("/usr/sbin/groupmod", "-g", "$www_gid", "www") == 0) + { + $rec->set_prop('errmsg', $rec->prop('errmsg').'
'. + $fm->localise('ERR_RESTORING_GID')); + warn ($fm->localise('ERR_RESTORING_GID')."\n"); + } + unless(system("/usr/sbin/usermod", "-g", "$www_gid", "www") == 0) + { + $rec->set_prop('errmsg', $rec->prop('errmsg').'
'. + $fm->localise('ERR_RESTORING_INITIAL_GRP')); + warn ($fm->localise('ERR_RESTORING_INITIAL_GRP')."\n"); + } + unless(system("/sbin/e-smith/signal-event", "post-upgrade") == 0) + { + $rec->set_prop('errmsg', $rec->prop('errmsg').'
'. + $fm->localise('ERR_UPDATING_CONF_AFTER_TAPE_RESTORE')); + $rec->delete_prop('state'); + die ($fm->localise('ERR_UPDATING_CONF_AFTER_TAPE_RESTORE')); + } + + my $finish = time; + $rec->set_prop('state', 'complete'); + $rec->set_prop('finish', $finish); + + my $start = $rec->prop('start'); + $start = scalar localtime($start); + $finish = scalar localtime($finish); + + &esmith::lockfile::UnlockFile($file_handle); + + exit; + } + else + { + # Error + + $rec->delete_prop('state'); + $rec->set_prop('errmsg', $fm->localise('COULD_NOT_FORK')); + die ($fm->localise("COULD_NOT_FORK")."$!\n"); + } +} + +sub WorkstnBackupConfig +{ + my ($q) = @_; + my $backupwk_status; + my $enabledIncOnlyTimeout = ""; + my $smbv1 = ""; + my $backupwkLogin = 'backup'; + my $backupwkPassword = 'backup'; + my $backupwkStation = 'host'; + my $backupwkFolder = 'share'; + my $backupwkMount = '/mnt/smb'; + my $setsNumber; + my $filesinset; + my $backupwkTime; + my $backupwkTimeout; + my $backupwkIncOnlyTimeout; + my $compression; + my $VFSType; + my $dof; + my @dlabels = split(' ', $fm->localise('DOW')); + my @VFST = ('cifs', 'nfs', 'usb','mnt'); + my %VFST = ('cifs', $fm->localise('cifs'), 'nfs', $fm->localise('nfs'), 'usb', $fm->localise('local removable disk'), 'mnt', $fm->localise('Mounted disk')); + + # Obtain backup informations from configuration + my $rec = $conf->get('backupwk'); + if ($rec) + { + $backupwkTime = $rec->prop('BackupTime') || '2:00'; + $backupwkLogin = $rec->prop('Login') || 'backup'; + $backupwkPassword = $rec->prop('Password') || 'backup'; + $backupwkStation = $rec->prop('SmbHost') || 'host'; + $backupwkFolder = $rec->prop('SmbShare') || 'share'; + $backupwkMount = $rec->prop('Mount') || '/mnt/smb'; + $setsNumber = $rec->prop('SetsMax') || '1'; + $filesinset = $rec->prop('DaysInSet') || '1'; + $backupwkTimeout = $rec->prop('Timeout') || '12'; + $backupwkIncOnlyTimeout = $rec->prop('IncOnlyTimeout') || 'yes'; + $compression = $rec->prop('Compression') || '0'; + $dof = (defined $rec->prop('FullDay')) ? $rec->prop('FullDay') : '7'; + $smbv1 = ( ($rec->prop('SmbV1') || 'disabled') eq "enabled" ) ? "enabled" : "disabled" ; + $VFSType = $rec->prop('VFSType') || 'cifs'; + $backupwk_status = $rec->prop('status'); + } + + esmith::cgi::genHeaderNonCacheable($q, undef, $fm->localise('CONFIGURE_WORKSTN_BACKUP')); + + if ($rec) + { + print $fm->localise('WORKSTN_BACKUP_DESC'); + print $fm->localise('WORKSTN_BACKUP_ENABLED'), $q->b(' '.$fm->localise(uc($backupwk_status))), '.
'; + if ($VFSType eq 'usb') + { + print $fm->localise('WORKSTN_BACKUP_USB'), ' ', $backupwkFolder, '
'; + } + elsif ($VFSType eq 'mnt') + { + print $fm->localise('WORKSTN_BACKUP_MNT'), ' ', $backupwkMount, '
'; + } + else + { + print $fm->localise('WORKSTN_BACKUP_HOST'), ' ', $backupwkStation; + print ' ', $fm->localise('WORKSTN_BACKUP_VFSTYPE'), ' ', $VFSType, '
'; + print $fm->localise('WORKSTN_BACKUP_SHARE'), ' ', $backupwkFolder, '
'; + } + if ($VFSType eq 'cifs') + { + print $fm->localise('LOGIN'), ' ', $backupwkLogin, '
'; + print $fm->localise('PASSWORD'), ' ********
'; + print $fm->localise('SMBV1'), ' ', $smbv1, '
'; + } + print $fm->localise('WORKSTN_BACKUP_SETSNUM'), ' ', $setsNumber, '
'; + print $fm->localise('WORKSTN_BACKUP_DAYSINSET'), ' ', $filesinset, '
'; + print $fm->localise('WORKSTN_BACKUP_COMPRESSION'), ' ', $compression, '
'; + print $fm->localise('WORKSTN_BACKUP_TOD'), ' ', $backupwkTime, '
'; + print $fm->localise('WORKSTN_BACKUP_TIMEOUT'), ' ', $backupwkTimeout, ' ', $fm->localise('HOURS'); + if ( $backupwkIncOnlyTimeout eq 'yes' ) + { + print $fm->localise('WORKSTN_BACKUP_INCONLY_TIMEOUT') + } + print '
'; + if ( $dof eq '7' ) + { + print $fm->localise('WORKSTN_FULL_BACKUP_EVERYDAY', '
'); + } + else + { + print $fm->localise('WORKSTN_FULL_BACKUP_DAY'), ' ', $dlabels[$dof], '
'; + } + } + else { print $fm->localise('WORKSTN_BACKUP_NOT_CONFIGURED'), '
' } + + print $q->startform( + -method => 'POST', + -action => $q->url (-absolute => 1) + ); + + print $q->start_table ({-class => "sme-noborders"}); + + print $q->Tr($q->td($q->h3 ($fm->localise('WORKSTATION_BACKUP_SETCONF')))); + + + print $q->Tr( + esmith::cgi::genCell( + $q, + $fm->localise('SELECT_VFS_TYPE') + ), + + esmith::cgi::genCell ($q, $q->popup_menu (-name => 'VFSType', + -values => [ @VFST ], + -labels => \%VFST, + -default => $VFSType))); + + print "\n"; + + print $q->start_table ({width => "100%", -class => "sme-noborders"}); + print $q->Tr($q->th({-class => "sme-layout"}, + $q->submit( + -name => 'action', + -value => $fm->localise('NEXT') + ) + ) + ); + + print $q->hidden( + -name => 'state', + -override => 1, + -default => 'workstn-configure' + ); + print ''; + + print $q->endform; + + esmith::cgi::genFooter ($q); + return; +} + +sub WorkstnBackupConfig1 +{ + my ($q) = @_; + my $enabledChk = ""; + my $enabledIncOnlyTimeout = ""; + my $backupwkAMPM = 'AM'; + my $backupwkMin; + my $backupwkHour; + my $backupwkLogin = 'backup'; + my $backupwkPassword = 'backup'; + my $backupwkStation = 'host'; + my $backupwkFolder = 'share'; + my $backupwkMount = ''; + my $setsNumber; + my $filesinset; + my $backupwkTimeout; + my $backupwkIncOnlyTimeout; + my $compression; + my $VFSType = $q->param ('VFSType'); + my $error=""; + my $dof; + my $smbv1 = ''; + my @usbdisks; + my %dlabels = (); + my @dlabels = split(' ', $fm->localise('DOW')); + my $i = 0; + foreach (@dlabels) { + $dlabels{$i} = $_; + $i++; + } + + # Obtain backup informations from configuration + my $rec = $conf->get('backupwk'); + my $backupwkTime = '2:00'; + if ($rec) + { + $backupwkTime = $rec->prop('BackupTime') || '2:00'; + $backupwkLogin = $rec->prop('Login') || 'backup'; + $backupwkPassword = $rec->prop('Password') || 'backup'; + $backupwkStation = $rec->prop('SmbHost') || 'host'; + $backupwkFolder = $rec->prop('SmbShare') || 'share'; + $backupwkMount = $rec->prop('Mount') || ''; + $setsNumber = $rec->prop('SetsMax') || '1'; + $filesinset = $rec->prop('DaysInSet') || '1'; + $backupwkTimeout = $rec->prop('Timeout') || '12'; + $backupwkIncOnlyTimeout = $rec->prop('IncOnlyTimeout') || 'yes'; + $compression = $rec->prop('Compression') || '0'; + $dof = (defined $rec->prop('FullDay')) ? $rec->prop('FullDay') : '7'; + $smbv1 = ( ($rec->prop('SmbV1') || 'disabled') eq "enabled" ) ? "checked" : "" ; + } + + ($backupwkHour, $backupwkMin) = split (':', $backupwkTime, -1); + + if ($backupwkHour > 12) + { + $backupwkHour -= 12; + $backupwkAMPM = 'PM'; + } + + my $backupwk_status; + if ($rec) + { + $backupwk_status = $rec->prop('status'); + } + + if (defined $backupwk_status && $backupwk_status eq 'enabled') + { + $enabledChk = 'checked'; + } + + if (defined $backupwkIncOnlyTimeout && $backupwkIncOnlyTimeout eq 'yes') + { + $enabledIncOnlyTimeout = 'checked'; + } + + esmith::cgi::genHeaderNonCacheable( + $q, undef, $fm->localise('CONFIGURE_WORKSTN_BACKUP')); + + if ( $VFSType eq 'usb' ) { + my $devices = esmith::BlockDevices->new ('allowmount' => 'disabled'); + my ($valid, $invalid) = $devices->checkBackupDrives(0); + + if ( ${$valid}[0] ) { + foreach ( @{$valid} ) { + push @usbdisks, $devices->label($_); + } + } + else + { + push @usbdisks, $fm->localise('ERR_NO_USB_DISK'); + $error='nousb'; + } + $devices->destroy; + } + if ( $VFSType eq 'mnt' ) + { + @usbdisks = findmnt (); + unless ($usbdisks[0]){ + push @usbdisks, $fm->localise('ERR_NO_MOUNTED_DISK'); + $error='nomnt'; + } + } + + + print $q->startform( + -method => 'POST', + -action => $q->url (-absolute => 1) + ); + + print $fm->localise('CONFIGURE_WORKSTN_BACKUP_DESC'); + + print $q->start_table ({-class => "sme-noborders"}); + + print $q->Tr( + $q->td( + $fm->localise('ENABLE_WORKSTN_BACKUP') + . " " + ) + ); + + print $q->Tr($q->td($q->h3 ($fm->localise('WORKSTATION_BACKUP_DEST')))); + + if ( $VFSType =~ m/cifs|nfs/s ) + { + print $q->Tr(esmith::cgi::genCell($q,$fm->localise('WORKSTN_NAME')), + esmith::cgi::genCell ($q, $q->textfield (-name => 'backupwkStation', + -override => 1, + -default => $backupwkStation, + -size => 20)), + ); + } + + if ( $VFSType eq 'usb' ) + { + print $q->Tr(esmith::cgi::genCell($q,$fm->localise('local removable disk')), + esmith::cgi::genCell ($q, $q->popup_menu (-name => 'backupwkFolder', + -values => [ @usbdisks ], + -default => $backupwkFolder,)), + ); + } + elsif ($VFSType eq 'mnt') + { + print $q->Tr(esmith::cgi::genCell($q,$fm->localise('Mounted disk')), + esmith::cgi::genCell ($q, $q->popup_menu (-name => 'backupwkFolder', + -values => [ @usbdisks ], + -default => $backupwkMount,)), + ); + } + else + { + print $q->Tr(esmith::cgi::genCell($q,$fm->localise('SHARED_FOLDER_NAME')), + esmith::cgi::genCell ($q, $q->textfield (-name => 'backupwkFolder', + -override => 1, + -default => $backupwkFolder, + -size => 20)), + ); + } + + if ( $VFSType eq 'cifs' ) { + print $q->Tr( + esmith::cgi::genCell( + $q, + $fm->localise('WORKSTN_LOGIN') + ), + + esmith::cgi::genCell ($q, $q->textfield (-name => 'backupwkLogin', + -override => 1, + -default => $backupwkLogin, + -size => 12)), + ); + + print $q->Tr( + esmith::cgi::genCell( + $q, + $fm->localise('PASSWORD') + ), + + esmith::cgi::genCell ($q, $q->password_field (-name => 'backupwkPassword', + -override => 1, + -default => $backupwkPassword, + -size => 20)), + ); +#smbv1 + print $q->Tr( + esmith::cgi::genCell( + $q, + $fm->localise('SMBV1') + ), + + esmith::cgi::genCell ( + $q, + " " + ), + + ); + + } + + print ''; + + print $q->table ({border => 0, cellspacing => 1, cellpadding => 4}); + + print $q->Tr($q->td({-colspan=>4},$q->h3 ($fm->localise('WORKSTN_BACKUP_SETTINGS')))); + + print $q->Tr( + esmith::cgi::genCell( + $q, + $fm->localise('NUMBER_OF_SETS') + ), + + esmith::cgi::genCell ($q, $q->textfield (-name => 'setsNumber', + -override => 1, + -default => $setsNumber, + -size => 3)), + + esmith::cgi::genCell ($q, $fm->localise('NUMBER_OF_FILES_IN_SET')), + esmith::cgi::genCell ($q, $q->textfield (-name => 'filesinset', + -override => 1, + -default => $filesinset, + -size => 3)) + ); + + print $q->Tr( + esmith::cgi::genCell( + $q, + $fm->localise('WORKSTN_BACKUP_TIME') + ), + + esmith::cgi::genCell ($q, $q->textfield (-name => 'backupwkHour', + -override => 1, + -default => $backupwkHour, + -size => 2)), + + esmith::cgi::genCell ($q, $q->textfield (-name => 'backupwkMin', + -override => 1, + -default => $backupwkMin, + -size => 2)), + + esmith::cgi::genCell ($q, $q->popup_menu (-name => 'backupwkAMPM', + -values => ['AM', 'PM'], + -default => $backupwkAMPM))); + + print $q->Tr( + esmith::cgi::genCell( + $q, + $fm->localise('WORKSTN_TIMEOUT') + ), + + esmith::cgi::genCell ($q, $q->textfield (-name => 'backupwkTimeout', + -override => 1, + -default => $backupwkTimeout, + -size => 2)), + + esmith::cgi::genCell( + $q, + $fm->localise('INC_ONLY_TIMEOUT') + ), + + esmith::cgi::genCell ( + $q, + " " + ), + ); + + print $q->Tr( + esmith::cgi::genCell( + $q, + $fm->localise('COMPRESSION_LEVEL') + ), + + esmith::cgi::genCell ($q, $q->textfield (-name => 'compression', + -override => 1, + -default => $compression, + -size => 1)), + + esmith::cgi::genCell( + $q, + $fm->localise('FULL_ONLY_ON') + ), + + esmith::cgi::genCell ( + $q, + $q->popup_menu ( + -name => 'dof', + -values => [ '7', '0', '1', '2', '3', '4', '5', '6' ], + -labels => \%dlabels, + -default => $dof)) + ); + + print "\n"; + + if ($error =~ m/nousb|nomnt/s) {$VFSType = $error;} + print $q->start_table ({width => "100%", -class => "sme-noborders"}); + print $q->Tr($q->th({-class => "sme-layout"}, + $q->submit( + -name => 'action', + -value => $fm->localise('UPDATE_CONF') + ) + ) + ); + + print $q->hidden( + -name => 'state', + -override => 1, + -default => 'workstn-configure1' + ); + print $q->hidden( + -name => 'VFSType', + -override => 1, + -default => $VFSType + ); + print ''; + + print $q->endform; + + esmith::cgi::genFooter ($q); + return; +} + +sub updateWorkstnBackupConfig +{ + my ($q) = @_; + + my $status = $q->param ('workstnbackup') || ""; + my $inconly = $q->param ('incOnlyTimeout'); + my $smbv1 = $q->param ('smbv1'); + my $dof = $q->param('dof'); + my $ampm; + my $incOnlyTimeout; + + esmith::cgi::genHeaderNonCacheable( + $q, + undef, $fm->localise('UPDATING_WORKSTN_CONF') + ); + + my $rec = $conf->get('backupwk'); + unless (defined $rec) + { + $rec = $conf->new_record('backupwk', {type=>'service'}); + } + my $backupwkMount = $rec->prop('Mount') || '/mnt/smb'; + + unless ( $status eq 'on') + { + # set service to disabled + my $old = $conf->get('UnsavedChanges')->value; + + $rec->set_prop('status', 'disabled'); + $conf->get('UnsavedChanges')->set_value($old); + + system("/sbin/e-smith/signal-event", "conf-backup") == 0 + or die($fm->localise('ERR_CONF_BACKUP')."\n"); + + esmith::cgi::genResult($q, $fm->localise('SUCCESSFULLY_DISABLED_WORKSTN')); + return; + } + + #-------------------------------------------------- + # Untaint parameters and check for validity + #-------------------------------------------------- + + my $VFSType = $q->param ('VFSType'); + if ( $VFSType eq 'nousb') + { + esmith::cgi::genResult($q, $fm->localise('ERR_NO_USB_DISK')); + return; + } + if ( $VFSType eq 'nomnt') + { + esmith::cgi::genResult($q, $fm->localise('ERR_NO_MOUNTED_DISK')); + return; + } + + my $backupwkStation = $q->param ('backupwkStation'); + if ( $VFSType =~ m/usb|mnt/s) { $backupwkStation = 'localhost' } + if ($backupwkStation =~ /^\s*(\S+)\s*$/) { + $backupwkStation = $1; + } else { + $backupwkStation = ""; + } + if ( $backupwkStation eq "" ) + { + esmith::cgi::genResult( + $q, $fm->localise('ERR_INVALID_WORKSTN') + ); + return; + } + + my $backupwkFolder = $q->param ('backupwkFolder'); + if ($backupwkFolder =~ /^(.*)$/) + { + $backupwkFolder = $1; + } + else + { + $backupwkFolder = ''; + } + if ( $VFSType eq 'usb' ) + { + $backupwkFolder = 'media/' . $backupwkFolder; + } + if ( $VFSType eq 'mnt' ) + { + $backupwkMount = $backupwkFolder; + if (checkMount ($backupwkMount)){$backupwkFolder = '';} + } + else + { + $backupwkFolder =~ s/^\///; # remove leading / + } + if ( $backupwkFolder eq '') + { + esmith::cgi::genResult($q, $fm->localise('ERR_INVALID_FOLDER')); + return; + } + + my $backupwkLogin = $q->param ('backupwkLogin') || ''; + if ($backupwkLogin =~ /^(.*)$/) { + $backupwkLogin = $1; + } else { + $backupwkLogin = ""; + } + if ( ( $backupwkLogin eq "" ) && ( $VFSType eq 'cifs' ) ) + { + esmith::cgi::genResult( + $q, $fm->localise('ERR_INVALID_LOGIN') + ); + return; + } + + my $backupwkPassword = $q->param ('backupwkPassword') || ''; + if ($backupwkPassword =~ /^(.*)$/) { + $backupwkPassword = $1; + } else { + $backupwkPassword = ""; + } + if ( ( $backupwkPassword eq "" ) && ( $VFSType eq 'cifs' ) ) + { + esmith::cgi::genResult( + $q, $fm->localise('ERR_INVALID_PASSWORD') + ); + return; + } + + my $setsNumber = $q->param ('setsNumber'); + unless ( $setsNumber > 0 ) + { + esmith::cgi::genResult( + $q, $fm->localise('ERR_INVALID_SETS_NUMBER') + ); + return; + } + + my $filesinset = $q->param ('filesinset'); + unless ( $filesinset > 0 ) + { + esmith::cgi::genResult( + $q, $fm->localise('ERR_INVALID_FILES_IN_SET_NUMBER') + ); + return; + } + + my $timeout = $q->param ('backupwkTimeout'); + if (( $timeout eq '') || ( $timeout == 0 )) {$timeout = 24 } + if (( $timeout < 1 ) || ( $timeout > 24 )) + { + esmith::cgi::genResult( + $q, $fm->localise('ERR_INVALID_TIMEOUT') + ); + return; + } + + if (defined $inconly && $inconly eq 'on') + { + $incOnlyTimeout = 'yes'; + } + else + { + $incOnlyTimeout = 'no'; + } + + if (defined $smbv1 && $smbv1 eq 'on') + { + $smbv1 = 'enabled'; + } + else + { + $smbv1 = 'disabled'; + } + + my $compression = $q->param ('compression'); + if (( $compression < 0 ) || ( $compression > 9 )) + { + esmith::cgi::genResult( + $q, $fm->localise('ERR_INVALID_COMPRESSION') + ); + return; + } + + $rec->set_prop('SmbHost', $backupwkStation); + $rec->set_prop('SmbShare', $backupwkFolder); + $rec->set_prop('SmbV1', $smbv1); + $rec->set_prop('Mount', $backupwkMount); + $rec->set_prop('Login', $backupwkLogin); + $rec->set_prop('Password', $backupwkPassword); + $rec->set_prop('SetsMax', $setsNumber); + $rec->set_prop('DaysInSet', $filesinset); + $rec->set_prop('Timeout', $timeout); + $rec->set_prop('IncOnlyTimeout', $incOnlyTimeout); + $rec->set_prop('Compression', $compression); + $rec->set_prop('FullDay', $dof); + $rec->set_prop('VFSType', $VFSType); + + my $module = $rec->prop('Program'); + + # The default workstation backup program is dar. + + unless (defined $module) + { + $module = 'dar'; + } + elsif ($module eq '') + { + $module = 'dar'; + } + + $rec->set_prop('Program', $module); + + my $backupwkHour = $q->param ('backupwkHour'); + if ($backupwkHour =~ /^(.*)$/) { + $backupwkHour = $1; + } else { + $backupwkHour = '12'; + } + if (($backupwkHour < 0) || ($backupwkHour > 12)) + { + esmith::cgi::genResult( + $q, $fm->localise('ERR_INVALID_HOUR').$backupwkHour. + $fm->localise('BETWEEN_0_AND_12') + ); + + return; + } + + my $backupwkMin = $q->param ('backupwkMin'); + if ($backupwkMin =~ /^(.*)$/) { + $backupwkMin = $1; + } else { + $backupwkMin = '0'; + } + if (($backupwkMin < 0) || ($backupwkMin > 59)) + { + esmith::cgi::genResult( + $q, $fm->localise('ERR_INVALID_MINUTE').$backupwkMin. + $fm->localise('BETWEEN_0_AND_59') + ); + + return; + } + + $backupwkMin = sprintf("%02d", $backupwkMin); + + $ampm = $q->param ('backupwkAMPM'); + if ($ampm =~ /^(.*)$/) { + $ampm = $1; + } else { + $ampm = 'AM'; + } + + # convert to 24 hour time + + $backupwkHour = $backupwkHour % 12; + if ($ampm eq 'PM') + { + $backupwkHour = $backupwkHour + 12; + } + + + # variables passed validity checks, set configuration database values + my $old = $conf->get('UnsavedChanges')->value; + + $rec->set_prop('status', 'enabled'); + + $rec->set_prop('BackupTime', "$backupwkHour:$backupwkMin"); + + $conf->get('UnsavedChanges')->set_value($old); + + system("/sbin/e-smith/signal-event", "conf-backup") == 0 + or die($fm->localise('ERR_CONF_BACKUP'),"\n"); + + # we test if the remote host is reachable, else we simply display a warning + if ( $VFSType =~ m/cifs|nfs/s ) + { + my $error_message = vmount($backupwkStation,$backupwkFolder,$backupwkMount,$VFSType,$smbv1); + if (! $error_message) + { + bunmount($backupwkMount,$VFSType); + } + elsif ($error_message) + { + esmith::cgi::genResult($q, $fm->localise('ERROR_WHEN_TESTING_REMOTE_SERVER').$q->br() . "$error_message"); + return; + } + } + + esmith::cgi::genResult( + $q, $fm->localise('SUCCESSFULLY_ENABLED_WORKSTN').$q->br(). + $fm->localise('WITH_BACKUP_TIME')."$backupwkHour:$backupwkMin"); + + return; +} + +sub workstnVerify () +{ + + my $rec = $conf->get('backupwk'); + + esmith::cgi::genHeaderNonCacheable ($q, undef, + $fm->localise('VERIFY_WORKSTN_BACKUP_FILE')); + + unless ($rec) + { + esmith::cgi::genResult( + $q, $fm->localise('CONFIGURATION_TO_BE_DONE')); + return; + } + + my %backupfiles = (); + my $mntdir = $rec->prop('Mount') || '/mnt/smb'; + my $mntbkdir; + my $key; + my $id = $rec->prop('Id') || $conf->get('SystemName')->value . "." . $conf->get('DomainName')->value; + my $smbhost = $rec->prop('SmbHost'); + my $smbshare = $rec->prop('SmbShare'); + my $smbv1 = $rec->prop('SmbV1') || 'disabled'; + my $VFSType = $rec->prop('VFSType') || 'cifs'; + my $err; + $mntdir = "/$smbshare" if ( $VFSType eq 'usb' ); + + my $setbackuplist = sub { + if ( $_ =~ /\.dar/ ) { + my $dir = $File::Find::dir; + my $backupref; + $dir =~ s/$mntbkdir\///; + $_ =~ s/\..*\.dar//; + $backupref = $_; + $_ =~ s/.*-//; + @{$backupfiles{$_}}[0] = $dir; + @{$backupfiles{$_}}[1] = $backupref; + } + }; + + # Mounting backup shared folder + my $error_message = bmount($mntdir,$smbhost,$smbshare,$VFSType,$smbv1); + if ($error_message) + { + esmith::cgi::genResult($q, $error_message, $id); + return; + } + + # Test if backup subdirectory for our server + $mntbkdir = $mntdir . "/$id"; + unless (-d $mntbkdir) + { + $error_message = $fm->localise('ERR_NO_HOST_DIR')."\n"; + $error_message .= bunmount($mntdir,$VFSType); + esmith::cgi::genResult($q, $error_message, $id); + return; + } + + # Finding existing backups + + find { wanted => \&$setbackuplist, untaint => 1, untaint_pattern => qr|^([-+@\w\s./]+)$|}, $mntbkdir ; + + my %blabels = (); + my @blabels; + my $backups = 0; + + foreach $key (sort keys %backupfiles) { + my $labkey = $mntbkdir . '/' . $backupfiles{$key}[0] . '/' . $backupfiles{$key}[1]; + $blabels{$labkey} = $backupfiles{$key}[1] . " (" . $backupfiles{$key}[0] . ")"; + $backups = push @blabels, $labkey; + } + + $error_message = bunmount($mntdir,$VFSType); + die($error_message) if $error_message; + + # Stops here if no backups + + if ( $backups == 0 ) { + esmith::cgi::genResult( + $q, $fm->localise('NO_BACKUPS_TO_RESTORE')); + return; + } + + print $q->p ($fm->localise('VERIFY_WORKSTN_BACKUP_DESC') . ' ' . "$smbhost/$smbshare/$id"); + print $q->p; + + print $q->start_multipart_form( + -method => 'POST', + -action => $q->url (-absolute => 1) + ); + + print $q->table ({border => 0, cellspacing => 0, cellpadding => 4}, + + esmith::cgi::genWidgetRow( + $q, + $fm->localise('SELECT_BACKUP_FILE'), + $q->popup_menu ( + -name => 'backupset', + -values => [ @blabels ], + -labels => \%blabels + ) + ) + ); + + print $q->table ({border => 0, cellspacing => 0, cellpadding => 4}, + + esmith::cgi::genWidgetRow( + $q, + $fm->localise('CHECK_TO_VERIFY_FULL_RESTORE'), + $q->checkbox ( + -name => 'verifyall', + -checked=>0, + -label=>'' + ) + ), + $q->Tr( + esmith::cgi::genTextRow( + $q, + $fm->localise('CHECK_INTEGRITY_WARNING') + ) + ) + ),"\n"; + + print $q->table ({width => "100%", -class => "sme-noborders"}, + esmith::cgi::genButtonRow( + $q, + $q->submit( + -name => 'action', + -value => $fm->localise('VERIFY') + ) + ) + ),"\n"; + + print $q->hidden( + -name => 'state', + -override => 1, + -default => 'workstn-verify' + ); + + print $q->endform; + + esmith::cgi::genFooter ($q); +} + +sub performWorkstnVerify +{ + my ($q) = @_; + + my $backupwkrec = $conf->get('backupwk'); + my $smbhost = $backupwkrec->prop('SmbHost'); + my $smbshare = $backupwkrec->prop('SmbShare'); + my $smbv1 = $backupwkrec->prop('SmbV1') || 'disabled'; + my $mntdir = $backupwkrec->prop('Mount') || '/mnt/smb'; + my $key; + my $error_message; + my $id = $backupwkrec->prop('Id') || + $conf->get('SystemName')->value . "." . $conf->get('DomainName')->value; + my $err; + my $VFSType = $backupwkrec->prop('VFSType') || 'cifs'; + my $verifyref = $q->param ('backupset'); + $mntdir = "/$smbshare" if ( $VFSType eq 'usb' ); + + # Mounting backup shared folder + $error_message = bmount($mntdir,$smbhost,$smbshare,$VFSType,$smbv1); + if ($error_message) + { + esmith::cgi::genResult($q, $error_message, $id); + return; + } + + # Test if backup subdirectory for our server + my $mntbkdir = $mntdir . "/$id"; + unless (-d $mntbkdir) + { + $error_message = $fm->localise('ERR_NO_HOST_DIR')."\n"; + $error_message .= bunmount($mntdir,$VFSType); + esmith::cgi::genResult($q, $error_message, $id); + return; + } + + my $fullverify = $q->param('verifyall') || ''; + + if ( $fullverify eq "on" ) + { + # Test all backups needed to full restore + + my %backupsetfiles = (); + my @restorefiles; + my $set = $verifyref; + $set =~ s/\/[^\/]*$//; + my $backupsetlist = sub { + if ( $_ =~ /\.dar/ ) + { + my $backupref = $File::Find::name; + $backupref =~ s/\.[0-9]+\.dar//; + $_ =~ s/\..*\.dar//; + $_ =~ s/.*-//; + $backupsetfiles{$_} = $backupref; + } + }; + + # find list of available backups and verify + # it contains all backups needed for full restore + + find { wanted => \&$backupsetlist, untaint => 1, untaint_pattern => qr|^([-+@\w\s./]+)$| }, $set ; + + my $key; + my $num = 0; + foreach $key (sort keys %backupsetfiles) + { + push @restorefiles, $backupsetfiles{$key}; + if ( $num == 0 ) + { + unless ( $backupsetfiles{$key} =~ /\/full-/ ) + { + esmith::cgi::genHeaderNonCacheable( + $q, + undef, $fm->localise('VERIFY_WORKSTN_BACKUP_FILE') + ); + esmith::cgi::genResult( + $q, $fm->localise('ERR_NO_FULL_BACKUP') + ); + return; + } + } + else + { + my $numf = sprintf("%03d", $num); + unless ( $backupsetfiles{$key} =~ /\/inc-$numf-/ ) + { + esmith::cgi::genHeaderNonCacheable( + $q, + undef, $fm->localise('VERIFY_WORKSTN_BACKUP_FILE') + ); + + esmith::cgi::genResult( + $q, $fm->localise('ERR_NO_INC_BACKUP') . " " . $numf + ); + return; + } + + } + $num++; + last if ( $backupsetfiles{$key} eq $verifyref ); + } + + # and test them + + $| = 1; + + if (open(RD, "-|")) + { + esmith::cgi::genHeaderNonCacheable ($q, undef, + $fm->localise('VERIFY_WORKSTN_BACKUP_FILE')); + + print $q->p ( + $q->b ($fm->localise('TESTING_NEEDED_BACKUPS_FOR_RESTORE') ) + ); + print '

    '; + + while () + { + print "
  • $_
  • \n"; + } + + print '
'; + my $message; + if (!close RD) + { + print $q->p ($q->b ( $fm->localise('RESTORE_VERIFY_FAILED') )); + } + else + { + print $q->p ($q->b ( $fm->localise('VERIFY_COMPLETE') )); + } + + esmith::cgi::genFooter ($q); + } + else + { + select(STDOUT); + $| = 1; + + my $file; + foreach $file (@restorefiles) + { + if ($file =~ /^(.*)$/) + { + $file = $1; + } + else + { + $error_message = "Unsecure data : $file\n"; + $error_message .= bunmount($mntdir,$VFSType); + die ($error_message); + } + print $q->p($fm->localise('TESTED_BACKUP') . " " . $file); + system ("/usr/bin/dar", "-Q", "--test", "$file", "--noconf"); + } + + $error_message = bunmount($mntdir,$VFSType); + die($error_message) if $error_message; + + exit(0); + } + return; + + } + else + { + # verify selected backup only + # and display files saved in the backup + + my $backupkey = $verifyref; + if ($backupkey =~ /^(.*)$/) + { + $backupkey = $1; + } + else + { + $error_message = "Unsecure data : $backupkey\n"; + $error_message .= bunmount($mntdir,$VFSType); + die ($error_message); + } + + if (open(RD, "-|")) + { + esmith::cgi::genHeaderNonCacheable ($q, + undef, $fm->localise('VERIFY_WORKSTN_BACKUP_FILE')); + print $q->p($fm->localise('FILES_IN_BACKUP')); + + print '
    '; + + my $complete = 0; + while () + { + $complete++ if /etc\/samba\/smbpasswd$/; + print "
  • $_
  • \n"; + } + + print '
'; + my $status = close RD ? + ($complete ? + $fm->localise('VERIFY_COMPLETE') : + $fm->localise('BACKUP_FILE_INCOMPLETE')) + : ($fm->localise('ERROR_READING_FILE').' : '.$backupkey); + print $q->p ($q->b ($status)); + + esmith::cgi::genFooter ($q); + + } + else + { + select(STDOUT); + $| = 1; + + system ("/usr/bin/dar", "-Q", "--list", "$backupkey", "--noconf") == 0 + or die ($fm->localise('ERR_EXTRACT')." : ".$!); + + $error_message = bunmount($mntdir,$VFSType); + die($error_message) if $error_message; + exit(0); + } + } + + return; +} + +sub workstnRestore () +{ + + my $rec = $conf->get('backupwk'); + + esmith::cgi::genHeaderNonCacheable( + $q, undef, $fm->localise('RESTORE_CONF_FROM_WORKSTN')); + + unless ($rec) + { + esmith::cgi::genResult( + $q, $fm->localise('CONFIGURATION_TO_BE_DONE')); + return; + } + + my $mntdir = $rec->prop('Mount') || '/mnt/smb'; + my $mntbkdir; + my %backupfiles = (); + my $key; + my $id = $rec->prop('Id') || + $conf->get('SystemName')->value . "." . $conf->get('DomainName')->value; + my $VFSType = $rec->prop('VFSType') || 'cifs'; + my $smbhost = $rec->prop('SmbHost'); + my $smbshare = $rec->prop('SmbShare'); + my $smbv1 = $rec->prop('SmbV1') || 'disabled'; + my $err; + $mntdir = "/$smbshare" if ( $VFSType eq 'usb' ); + + my $setbackupflist = sub { + if ( $_ =~ /\.dar/ ) + { + my $dir = $File::Find::dir; + my $backupref; + $dir =~ s/$mntbkdir\///; + $_ =~ s/\..*\.dar//; + $backupref = $_; + $_ =~ s/.*-//; + @{$backupfiles{$_}}[0] = $dir; + @{$backupfiles{$_}}[1] = $backupref; + } + }; + + # Mounting backup shared folder + my $error_message = bmount($mntdir,$smbhost,$smbshare,$VFSType,$smbv1); + if ($error_message) + { + esmith::cgi::genResult($q, $error_message, $id); + return; + } + + # Test if backup subdirectory for our server + $mntbkdir = $mntdir . "/$id"; + unless (-d $mntbkdir) + { + $error_message = $fm->localise('ERR_NO_HOST_DIR')."\n"; + $error_message .= bunmount($mntdir,$VFSType); + esmith::cgi::genResult($q, $error_message, $id); + return; + } + + # Finding existing backups + + find { wanted => \&$setbackupflist, untaint => 1, untaint_pattern => qr|^([-+@\w\s./]+)$| }, $mntbkdir ; + + my %blabels = (); + my @blabels; + my $backups = 0; + + foreach $key (sort keys %backupfiles) + { + my $labkey = $mntbkdir . '/' . $backupfiles{$key}[0] . '/' . $backupfiles{$key}[1]; + $blabels{$labkey} = $backupfiles{$key}[1] . ' (' . $backupfiles{$key}[0] . ')'; + $backups = push @blabels, $labkey; + } + + $error_message = bunmount($mntdir,$VFSType); + die($error_message) if $error_message; + + if ( $backups == 0 ) + { + esmith::cgi::genResult( + $q, $fm->localise('NO_BACKUPS_TO_RESTORE')); + return; + } + + print $q->p ($fm->localise('RESTORE_CONF_FROM_WORKSTN_DESC') . ' ' . "$smbhost/$smbshare/$id"); + print $q->p; + + print $q->start_multipart_form( + -method => 'POST', + -action => $q->url (-absolute => 1) + ); + + print $q->table ( {border => 0, cellspacing => 0, cellpadding => 4}, + esmith::cgi::genTextRow( + $q, + $q->b($fm->localise('DO_NOT_RESTORE_BIN_SBIN_LIB_LIB64_FROM_SME9')), + ), + + esmith::cgi::genWidgetRow( + $q, + $fm->localise('SELECT_BACKUP_FILE'), + $q->popup_menu ( + -name => 'backuptorestore', + -values => [ @blabels ], + -labels => \%blabels + ) + ) + ); + + print $q->table ( {width => "100%", -class => "sme-noborders"}, + esmith::cgi::genButtonRow( + $q, + $q->submit( + -name => 'action', + -value => $fm->localise('RESTORE_FROM_WORKSTN') + ) + ) + ); + + print $q->hidden( + -name => 'state', + -override => 1, + -default => 'workstn-restore' + ); + + print $q->endform; + + esmith::cgi::genFooter ($q); +} + +sub performWorkstnRestore +{ + my ($q) = @_; + my $restoreref = $q->param ('backuptorestore'); + my $set = $restoreref; + $set =~ s/\/[^\/]*$//; + my %backupsetfiles = (); + my @restorefiles; + + my $backupsetlist = sub { + if ( $_ =~ /\.dar/ ) + { + my $backupref = $File::Find::name; + $backupref =~ s/\.[0-9]+\.dar//; + $_ =~ s/\..*\.dar//; + $_ =~ s/.*-//; + $backupsetfiles{$_} = $backupref; + } + }; + + + my $lock_file = "/var/lock/subsys/e-smith-restore"; + my $file_handle = &esmith::lockfile::LockFileOrReturn($lock_file); + + unless ($file_handle) + { + esmith::cgi::genHeaderNonCacheable( + $q, + undef, $fm->localise('RESTORE_CANNOT_PROCEED') + ); + + print $q->p ( + $q->b ($fm->localise('ANOTHER_RESTORE_IN_PROGRESS') + ) + ); + + esmith::cgi::genFooter ($q); + return; + } + + my $backupwkrec = $conf->get('backupwk'); + my $id = $backupwkrec->prop('Id') + || $conf->get('SystemName')->value . "." . $conf->get('DomainName')->value; + my $mntdir = $backupwkrec->prop('Mount') || '/mnt/smb'; + my $VFSType = $backupwkrec->prop('VFSType') || 'cifs'; + my $smbhost = $backupwkrec->prop('SmbHost'); + my $smbshare = $backupwkrec->prop('SmbShare'); + my $smbv1 = $backupwkrec->prop('SmbV1') || 'disabled'; + $mntdir = "/$smbshare" if ( $VFSType eq 'usb' ); + my $err; + my $error_message; + + # Mounting backup shared folder + $error_message = bmount($mntdir,$smbhost,$smbshare,$VFSType,$smbv1); + if ($error_message) + { + esmith::cgi::genHeaderNonCacheable($q,undef, $fm->localise('RESTORE_CANNOT_PROCEED')); + esmith::cgi::genResult($q, $error_message, $id); + return; + } + + # Test if backup subdirectory for our server + my $mntbkdir = $mntdir . "/$id"; + unless (-d $mntbkdir) + { + $error_message = $fm->localise('ERR_NO_HOST_DIR')."\n"; + $error_message .= bunmount($mntdir,$VFSType); + esmith::cgi::genHeaderNonCacheable($q,undef, $fm->localise('RESTORE_CANNOT_PROCEED')); + esmith::cgi::genResult($q, $error_message, $id); + return; + } + + # finding list of available backups + # and verifying all needed backup files are available + + find { wanted => \&$backupsetlist, untaint => 1, untaint_pattern => qr|^([-+@\w\s./]+)$| }, $set ; + + my $key; + my $num = 0; + foreach $key (sort keys %backupsetfiles) + { + push @restorefiles, $backupsetfiles{$key}; + if ( $num == 0 ) + { + unless ( $backupsetfiles{$key} =~ /\/full-/ ) + { + esmith::cgi::genHeaderNonCacheable( + $q, + undef, $fm->localise('RESTORE_CANNOT_PROCEED') + ); + esmith::cgi::genResult( + $q, $fm->localise('ERR_NO_FULL_BACKUP') + ); + return; + } + } + else + { + my $numf = sprintf("%03d", $num); + unless ( $backupsetfiles{$key} =~ /\/inc-$numf-/ ) + { + esmith::cgi::genHeaderNonCacheable( + $q, + undef, $fm->localise('RESTORE_CANNOT_PROCEED') + ); + + esmith::cgi::genResult( + $q, $fm->localise('ERR_NO_INC_BACKUP') . $numf + ); + return; + } + + } + $num++; + last if ( $backupsetfiles{$key} eq $restoreref ); + } + + # backup is online, restoring now + + my $rec = $restore->get('restore'); + $rec->set_prop('state','running'); + $rec->set_prop('start', time); + $conf->get('bootstrap-console')->set_prop('Run', 'yes'); + + unless (system("/sbin/e-smith/signal-event", "pre-restore") == 0) + { + esmith::cgi::genHeaderNonCacheable( + $fm->{cgi}, + undef, $fm->localise('OPERATION_STATUS_REPORT')); + esmith::cgi::genResult( + $fm->{cgi}, $fm->localise('ERR_PRE_RESTORE')); + return; + } + + $| = 1; + + if (open(RD, "-|")) + { + + #----------------------------------------------------- + # restore system from uploaded workstation backup file + #----------------------------------------------------- + + esmith::cgi::genHeaderNonCacheable ($q, undef, + $fm->localise('RESTORE_IN_PROGRESS')); + + print $q->p ( + $q->b ($fm->localise('RESTORE_IN_PROGRESS_DESC') + ) + ); + + print $q->p($fm->localise('FILES_HAVE_BEEN_RESTORED')); + + print '
    '; + my $complete = 0; + while () + { + $complete++ if /etc\/samba\/smbpasswd$/; + print "
  • $_
  • \n"; + } + + print '
'; + my $message; + if (!close RD) + { + $message = $fm->localise('RESTORE_FAILED_MSG'); + } + else + { + #----------------------------------------------------- + # if restore completed, regenerate configuration files + #----------------------------------------------------- + if ($complete) + { + + $message = $fm->localise('RESTORE_COMPLETE'); + system("/usr/sbin/groupmod", "-g", "$www_gid", "www") == 0 + or warn ($fm->localise('ERR_RESTORING_GID')."\n"); + system("/usr/sbin/usermod", "-g", "$www_gid", "www") == 0 + or warn ($fm->localise('ERR_RESTORING_INITIAL_GRP')."\n"); + system("/sbin/e-smith/signal-event", "post-upgrade") == 0 + or die ($fm->localise('ERROR_UPDATING_CONFIGURATION')."\n"); + } + else + { + $message = $fm->localise('RESTORE_FAILED'); + } + } + + $rec->set_prop('state', 'complete'); + $rec->set_prop('finish', time); + + &esmith::lockfile::UnlockFile($file_handle); + + print $q->p ($q->b ($message)); + + print $q->startform( + -method => 'POST', + -action => $q->url (-absolute => 1) + ); + print $q->p($q->b ($fm->localise('YOU_MUST_REBOOT'))),"\n"; + print $q->start_table ({width => "100%", -class => "sme-noborders"}),"\n"; + print esmith::cgi::genButtonRow( + $q, + $q->submit (-name => 'action', -value => + $fm->localise('REBOOT')) + ); + # Put in a hidden widget to store the reboot value. + print $q->hidden( + -name => 'function', + -value => 'reboot' + ),"\n"; + print $q->hidden ( + -name => 'state', + -override => 1, + -default => 'perform' + ),"\n"; + print $q->end_table,"\n"; + print $q->endform; + + esmith::cgi::genFooter ($q); + } + else + { + select(STDOUT); + $| = 1; + + my $file; + foreach $file (@restorefiles) + { + if ($file =~ /^(.*)$/) + { + $file = $1; + } + else + { + $error_message = "Unsecure data : $file\n"; + $error_message .= bunmount($mntdir,$VFSType); + die ($error_message); + } + # because CentOS 7/SME 10 has now links in place of folder for bin lib lib64 and sbin, we need to exclude them to avoid to trash the server + # if restoring from a previous SME version. An alternative or complement to exclud directories would be to add this rule : '-/{!T&~D}[Pp];Oo' : do not replace symlink by dir, otherwise replace. + system ("/usr/bin/dar", "-Q", "-x", "$file", "-v", "-N", "-R", "/", "-wa", '-P', 'bin', '-P', 'lib', '-P', 'lib64', '-P', 'sbin', '-P', 'var/run', '-P', 'var/lock'); + # However if one has added element to backup to this location; we need to resore them to their new location + # TODO condition to execute or not the following .... + # something like dar -l full-20210309124352 -g bin -g lib -g lib64 -g sbin -/'{T}[Pp]'|grep -E '(sbin|bin|lib)'|wc -l ; if result > to 4 + # or with a loop accross the 4 locations + system ("/usr/bin/dar", "-Q", "-x", "$file", "-v", "-N", "-R", "/usr/", "-wa", '-g', 'bin', '-g', 'lib', '-g', 'lib64', '-g', 'sbin', '-D'); + } + + $error_message = bunmount($mntdir,$VFSType); + die($error_message) if $error_message; + + exit(0); + } + return; +} + +sub workstnSelRestore() +{ + my $rec = $conf->get('backupwk'); + + esmith::cgi::genHeaderNonCacheable ($q, undef, + $fm->localise('WORKSTN_SELECTIVE_RESTORE')); + + unless ($rec) + { + esmith::cgi::genResult( + $q, $fm->localise('CONFIGURATION_TO_BE_DONE')); + return; + } + + my %backupfiles = (); + my $mntdir = $rec->prop('Mount') || '/mnt/smb'; + my $mntbkdir; + my $key; + my $id = $rec->prop('Id') || + $conf->get('SystemName')->value . '.' . $conf->get('DomainName')->value; + my %blabels = (); + my @blabels; + my $backups = 0; + my $filterexp; + my $VFSType = $rec->prop('VFSType') || 'cifs'; + my $smbhost = $rec->prop('SmbHost'); + my $smbshare = $rec->prop('SmbShare'); + my $smbv1 = $rec->prop('SmbV1') || 'disabled'; + $mntdir = "/$smbshare" if ( $VFSType eq 'usb' ); + my $err; + my $error_message; + + my $setbackuplist = sub { + if ( $_ =~ /\.dar/ ) + { + my $dir = $File::Find::dir; + my $backupref; + $dir =~ s/$mntbkdir\///; + $_ =~ s/\..*\.dar//; + $backupref = $_; + $_ =~ s/.*-//; + @{$backupfiles{$_}}[0] = $dir; + @{$backupfiles{$_}}[1] = $backupref; + } + }; + + # Mounting backup shared folder + $error_message = bmount($mntdir,$smbhost,$smbshare,$VFSType,$smbv1); + if ($error_message) + { + esmith::cgi::genResult($q, $error_message, $id); + return; + } + + # Test if backup subdirectory for our server + $mntbkdir = $mntdir . "/$id"; + unless (-d $mntbkdir) + { + $error_message = $fm->localise('ERR_NO_HOST_DIR')."\n"; + $error_message .= bunmount($mntdir,$VFSType); + esmith::cgi::genResult($q, $error_message, $id); + return; + } + + my $catalog = "$mntbkdir/dar-catalog"; + my $i = 0; + my $j = 0; + my @bknum; + my @setd; + my @bkname; + + + # update backups list from current catalog + + open(DAR_LIST, "/usr/bin/dar_manager -B $catalog -l |") ; + + $i = 0; + while () + { + next unless m/set/; + chomp; + ($bknum[$i], $setd[$i], $bkname[$i]) = split(' ', $_, 3); + $i++; + } + close (DAR_LIST); + + # set drop down list of backups + + push @blabels, "0"; + $blabels{"0"} = $fm->localise('ALL_BACKUPS'); + $j = 0; + while ($j < $i) + { + push @blabels, $bknum[$j]; + $blabels{$bknum[$j]} = $bkname[$j]; + $j++ + } + + print $q->p ($fm->localise('WORKSTN_SEL_REST_DESC') . " $smbhost/$smbshare/$id"); + + print $q->h2 ($fm->localise('BACKUP_CHOICE')); + + print $q->start_multipart_form( + -method => 'POST', + -action => $q->url (-absolute => 1) + ); + + + print $q->table ({border => 0, cellspacing => 0, cellpadding => 4}, + + esmith::cgi::genWidgetRow( + $q, + $q->b($fm->localise('SELECT_BACKUP_FILE')), + $q->popup_menu ( + -name => 'backupset', + -values => [ @blabels ], + -labels => \%blabels) + ), + + esmith::cgi::genNameValueRow( + $q, + $fm->localise('FILTER_EXPRESSION'), + 'filterexp', + $filterexp + ) + ); + + + print $q->table ({width => "100%", -class => "sme-noborders"}, + esmith::cgi::genButtonRow( + $q, + $q->submit( + -name => 'action', + -value => $fm->localise('PERFORM') + ) + ) + ),"\n"; + + print $q->hidden( + -name => 'state', + -override => 1, + -default => 'workstn-sel-restore' + ); + + print $q->endform; + + + esmith::cgi::genFooter ($q); + + $error_message = bunmount($mntdir,$VFSType); + die($error_message) if $error_message; +} + +sub performWorkstnSelRestore +{ + my ($q) = @_; + + my $rgfilter; + my $filterexp = $q->param ('filterexp'); + if ($filterexp =~ /^(.*)$/) + { + $filterexp = $1; + $rgfilter = qr/$filterexp/; + } + else + { + $filterexp = ""; + } + my $seldatebf; + + esmith::cgi::genHeaderNonCacheable ($q, + undef, $fm->localise('WORKSTN_SELECTIVE_RESTORE')); + + my $backupwkrec = $conf->get('backupwk'); + my $smbhost = $backupwkrec->prop('SmbHost'); + my $smbshare = $backupwkrec->prop('SmbShare'); + my $smbv1 = $backupwkrec->prop('SmbV1') || 'disabled'; + my $mntdir = $backupwkrec->prop('Mount') || '/mnt/smb'; + my $key; + my $id = $backupwkrec->prop('Id') || + $conf->get('SystemName')->value . "." . $conf->get('DomainName')->value; + my @flabels; + my %flabels = (); + my $VFSType = $backupwkrec->prop('VFSType') || 'cifs'; + my $err; + my $error_message; + $mntdir = "/$smbshare" if ( $VFSType eq 'usb' ); + + my $backupkey = $q->param ('backupset'); + if ($backupkey =~ /^(.*)$/) + { + $backupkey = $1; + } + else + { + die('Unsecure data : ' . $backupkey); + } + + # Mounting backup shared folder + $error_message = bmount($mntdir,$smbhost,$smbshare,$VFSType,$smbv1); + if ($error_message) + { + esmith::cgi::genResult($q, $error_message, $id); + return; + } + + # Test if backup subdirectory for our server + my $mntbkdir = $mntdir . "/$id"; + unless (-d $mntbkdir) + { + $error_message = $fm->localise('ERR_NO_HOST_DIR')."\n"; + $error_message .= bunmount($mntdir,$VFSType); + esmith::cgi::genResult($q, $error_message, $id); + return; + } + + # Read wanted file list from selected backup + + if (open(RD, "-|")) + { + my $regex = qr/\[.*\] */; + while () + { + chomp; + $_ =~ s/$regex//; + next if m/^(sbin|bin|lib|lib64|var\/run|var\/lock)$/; + if ($filterexp) {next unless m/$rgfilter/}; + push @flabels, $_; + } + + my $status = close RD ? + $fm->localise('READ_COMPLETE') + : ($fm->localise('ERROR_READING_FILE').' : '.$backupkey); + print $q->p ($status); + + } + else + { + select(STDOUT); + $| = 1; + + system ("/usr/bin/dar_manager", "-B", "$mntbkdir/dar-catalog", "-u", "$backupkey") == 0 + or die ($fm->localise('ERR_EXTRACT')." : ".$!); + + $error_message = bunmount($mntdir,$VFSType); + die($error_message) if $error_message; + exit(0); + } + + print $q->start_multipart_form( + -method => 'POST', + -action => $q->url (-absolute => 1) + ); + + print $q->table ({border => 0, cellspacing => 0, cellpadding => 4}, + + esmith::cgi::genTextRow( + $q, + $q->b($fm->localise('DO_NOT_RESTORE_BIN_SBIN_LIB_LIB64_FROM_SME9')), + ), + + esmith::cgi::genWidgetRow( + $q, + $q->b($fm->localise('SELECT_FILES_TO_RESTORE')), + $q->scrolling_list ( + -name => 'restorefiles', + -values => [ @flabels ], + -size => 15, + -multiple => 'true') + ), + + esmith::cgi::genNameValueRow( + $q, + $fm->localise('SELECT_DATE_BEFORE'), + 'seldatebefore', + $seldatebf + ) + ); + + print $q->table ({width => "100%", -class => "sme-noborders"}, + esmith::cgi::genButtonRow( + $q, + $q->submit( + -name => 'action', + -value => $fm->localise('PERFORM') + ) + ) + ),"\n"; + + print $q->hidden( + -name => 'state', + -override => 1, + -default => 'workstn-sel-restore2' + ); + + print $q->hidden( + -name => 'when', + -override => 1, + -value => $seldatebf + ); + + print $q->endform; + + esmith::cgi::genFooter ($q); + +} + +sub performWorkstnSelRestore2 +{ + my ($q) = @_; + + esmith::cgi::genHeaderNonCacheable ($q, undef, + $fm->localise('RESTORE_IN_PROGRESS')); + + my @restorelist; + my $when = $q->param ('seldatebefore'); + if ($when =~ /^(.*)$/) + { + $when = $1; + } + else + { + die('Unsecure data : ' . $when); + } + my $tymd = + qr/((19|20)\d\d\/(?=\d\d\/\d\d-))?((0?[1-9]|1[0-2])\/(?=\d\d-))?((31|[123]0|[012]?[1-9])-)?/; + my $thms = + qr/([01]?[0-9]|2[0-3]):([0-5][0-9])(:[0-5][0-9])?/; + + unless (($when =~ m/^$tymd$thms$/) || ($when eq "")) + { + esmith::cgi::genResult( + $q, "$when : " . $fm->localise('ERR_INVALID_SELDATE') + ); + return; + } + + my @restorefiles = $q->param ('restorefiles'); + my $f; + foreach $f (@restorefiles) + { + if ($f =~ /^(.*)$/) + { + push @restorelist, "\"".$1."\""; + } + } + + my $backupwkrec = $conf->get('backupwk'); + my $id = $backupwkrec->prop('Id') || + $conf->get('SystemName')->value . "." . $conf->get('DomainName')->value; + my $mntdir = $backupwkrec->prop('Mount') || '/mnt/smb'; + my $VFSType = $backupwkrec->prop('VFSType') || 'cifs'; + my $smbhost = $backupwkrec->prop('SmbHost'); + my $smbshare = $backupwkrec->prop('SmbShare'); + my $smbv1 = $backupwkrec->prop('SmbV1') || 'disabled'; + my $err; + my $error_message; + $mntdir = "/$smbshare" if ( $VFSType eq 'usb' ); + + # Mounting backup shared folder + $error_message = bmount($mntdir,$smbhost,$smbshare,$VFSType,$smbv1); + if ($error_message) + { + esmith::cgi::genResult($q, $error_message, $id); + return; + } + + # Test if backup subdirectory for our server + my $mntbkdir = $mntdir . "/$id"; + unless (-d $mntbkdir) + { + $error_message = $fm->localise('ERR_NO_HOST_DIR')."\n"; + $error_message .= bunmount($mntdir,$VFSType); + esmith::cgi::genResult($q, $error_message, $id); + return; + } + + # backup is online, restoring now + + $| = 1; + my $restorerr; + + if (open(RD, "-|")) + { + + #----------------------------------------------------- + # restore system from uploaded workstation backup file + #----------------------------------------------------- + + print $q->p($fm->localise('FILES_HAVE_BEEN_RESTORED')); + + print '
    '; + while () + { + print "
  • $_
  • \n"; + } + + print '
'; + my $message; + if (!close RD) + { + $message = $fm->localise('RESTORE_FAILED_MSG'); + } + else + { + if ($restorerr) + { + $message = $fm->localise('RESTORE_FAILED'); + } + else + { + $message = $fm->localise('RESTORE_COMPLETE'); + } + } + + print $q->p ($q->b ($message)); + + esmith::cgi::genFooter ($q); + } + else + { + select(STDOUT); + $| = 1; + # we could add this filter here -/{!T&~D}[Pp];Oo to prevent symlinks to be transformed as folder, but it would lead to $?=4 or 5 or 1024.... thus marking as failed + if ($when) + { + $restorerr = system ("/usr/bin/dar_manager -B \"$mntbkdir/dar-catalog\" -Q -w $when -e '-v -N -R / -w -P sbin -P bin -P lib64 -P lib -P var/run -P var/lock' -r @restorelist"); + } + else + { + $restorerr = system ("/usr/bin/dar_manager -B \"$mntbkdir/dar-catalog\" -Q -k -e '-v -N -R / -w -P sbin -P bin -P lib64 -P lib -P var/run -P var/lock' -r @restorelist"); + } + + $error_message = bunmount($mntdir,$VFSType); + die($error_message) if $error_message; + exit(0); + } + return; +} + +sub performReboot () +{ + esmith::cgi::genHeaderNonCacheable ($q, undef, + $fm->localise('SERVER_REBOOT')); + + print $q->p ( + $q->b ($fm->localise('SERVER_WILL_REBOOT')) + ); + + esmith::cgi::genFooter($fm); + + esmith::util::backgroundCommand( + 5, + "/sbin/e-smith/signal-event", + "reboot" + ); +} + +sub CalculateSizes () +{ + #------------------------------------------------------------ + # figure out the size of the tar file. + #------------------------------------------------------------ + + my $tarsize = 0; + + # It takes way too much time to do a du on /home/e-smith. So we'll + # estimate the current size. + # We do this by checking the quota used by each user on the system. + + use Quota; + use esmith::AccountsDB; + my $accounts = esmith::AccountsDB->open; + + # Get a $dev value appropriate for use in Quota::query call. + my $dev = Quota::getqcarg("/home/e-smith/files"); + + foreach my $user ($accounts->users()) + { + my $name = $user->key; + my $uid = getpwnam($name); + unless ($uid) + { + warn ($fm->localise('NO_UID_FOR_NAME').$name."\n"); + # We shouldn't ever get here. If we do, we can't get + # the quota value for this user, so we just skip to + # the next one. + next; + } + + # Get current quota settings. + my ($blocks) = Quota::query($dev, $uid, 0); + $tarsize += $blocks; + } + + # We add to this the size of root owned firectories, estimated using du. + # If this takes too long, then the admin only has his or + # herself to blame! + + # Remove /home/e-smith from backup list, and make paths absolute + my @list = map { "/$_" } grep { !/home\/e-smith/ } @directories; + open(DU, "-|") + or exec '/usr/bin/du', '-s', @list; + + while () + { + my ($du) = split(/\s+/); + $tarsize += $du; + } + close DU; + + $tarsize = &showSize($tarsize); + + #------------------------------------------------------------ + # figure out the size of the dump files + #------------------------------------------------------------ + + my $dumpsize = 0; + + open(DF, "-|") + or exec '/bin/df', '-P', '-t', 'ext3', '-t', 'ext4', '-t', 'xfs'; + + while () + { + next unless (/^\//); + + (undef, undef, my $s, undef) = split(/\s+/, $_); + + $dumpsize += $s; + } + + # increase size by 10% to cope with dump overhead. + + $dumpsize *= 1.1; + + close DF; + + $dumpsize = &showSize($dumpsize); + + #------------------------------------------------------------ + # how much free space is in /tmp + #------------------------------------------------------------ + + my $tmpfree = 0; + my $halffree = 0; + + open(DF, "-|") + or exec '/bin/df', '-P', '-t', 'ext3', '-t', 'ext4', '-t', 'xfs', '/tmp'; + + while () + { + next unless (/^\//); + + (undef, undef, undef, my $s) = split(/\s+/, $_); + + $tmpfree += $s; + } + + close DF; + + $halffree = $tmpfree / 2; + + $tmpfree = &showSize($tmpfree); + $halffree = &showSize($halffree); + + return ($tarsize, $dumpsize, $tmpfree, $halffree); +} + +sub showSize +{ + # convert size to Mb or Gb or Tb :) Remember, df reports in kb. + + my $size = shift; + + my $Mb = 1024; + my $Gb = $Mb * $Mb; + my $Tb = $Mb * $Mb * $Mb; + + if ($size >= $Tb) + { + $size /= $Tb; + $size = int($size) . "Tb"; + } + elsif ($size >= $Gb) + { + $size /= $Gb; + $size = int($size) . "Gb"; + } + elsif ($size >= $Mb) + { + $size /= $Mb; + $size = int($size) . "Mb"; + } + else + { + $size .= "kb"; + } + + return $size; +} + +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 checkMount +{ + # check if $mountdir is mounted + my $mountdir = shift; + $|=1; # Auto-flush + + my @res = qx( findmnt $mountdir ); + return ( !@res ); +} + +sub bmount +{ + my ($mntdir,$host,$share,$VFSType,$smbv1) = @_; + # verify backup directory not already mounted + + if (!checkMount ($mntdir)) + { + return if ($VFSType eq 'mnt'); + return ($fm->localise('ERR_ALREADY_MOUNTED')); + } + else + { + if ($VFSType eq 'mnt') + { + return ($fm->localise('ERR_NOT_MOUNTED')); + } + } + + # create the directory mount point if it does not exist + my $err = createTree ($mntdir); + return ($fm->localise('ERR_MOUNTING_SMBSHARE') . "\n" . $err) if $err; + + # mount the backup directory + $err = dmount($host,$share,$mntdir,'','',$VFSType,$smbv1); + return ($fm->localise('ERR_MOUNTING_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)) + { + return ($fm->localise('ERR_NOT_MOUNTED')); + } + } + return; +} + +sub bunmount +{ + my ($mount,$type) = @_; + return if ($type eq 'mnt'); # Don't unmount for type 'mnt' + + if (!checkMount ($mount)) + { + system('/bin/umount', '-f', $mount) == 0 + or return ($fm->localise('ERR_WHILE_UNMOUNTING')); + } + return; +} + +sub findmnt +{ + my @mntin = qx( findmnt -n -l -o TARGET ); + my @mntout; + + foreach my $mount (@mntin) + { + next if ($mount =~ m/^\/proc|^\/dev|^\/sys|^\/boot/s); + chomp $mount; + next if ($mount eq '/'); + push @mntout, $mount; + } + + return @mntout; +} + +sub createTree +{ + my $tree = shift; + if (! -d "$tree") + { + eval {make_path("$tree")}; + return ("Error while creating $tree : $@. Maybe insufficient rights directory.\n") if $@; + } + return; +} + +#Used to test if the remote share is mountable when you save settings in database +sub vmount +{ + # mount dar unit according to dar-workstation configuration in order to test the remote host + # return nothing if mount successfull + my ($host,$share,$mountdir,$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,timeo=30,retrans=1,retry=0 "$host:/$share" $mountdir 2>&1) ); + } + +} + +__DATA__ +
+
diff --git a/root/mnt/smb/.gitignore b/root/mnt/smb/.gitignore new file mode 100644 index 0000000..e69de29 diff --git a/root/sbin/e-smith/console-menu-items/usbBackup.pl b/root/sbin/e-smith/console-menu-items/usbBackup.pl new file mode 100644 index 0000000..af605d9 --- /dev/null +++ b/root/sbin/e-smith/console-menu-items/usbBackup.pl @@ -0,0 +1,3 @@ +package esmith::console::perform_backup; +use esmith::console::perform_backup; +return new esmith::console::perform_backup; diff --git a/root/sbin/e-smith/console-menu-items/usbRestore.pl b/root/sbin/e-smith/console-menu-items/usbRestore.pl new file mode 100644 index 0000000..4b6c6ab --- /dev/null +++ b/root/sbin/e-smith/console-menu-items/usbRestore.pl @@ -0,0 +1,3 @@ +package esmith::console::perform_restore; +use esmith::console::perform_restore; +return new esmith::console::perform_restore; diff --git a/root/sbin/e-smith/do_backup b/root/sbin/e-smith/do_backup new file mode 100644 index 0000000..3b744d3 --- /dev/null +++ b/root/sbin/e-smith/do_backup @@ -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; + } +} diff --git a/root/sbin/e-smith/do_backupwk b/root/sbin/e-smith/do_backupwk new file mode 100644 index 0000000..221c877 --- /dev/null +++ b/root/sbin/e-smith/do_backupwk @@ -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; + } +} diff --git a/root/usr/share/locale/en_US/LC_MESSAGES/backup.po b/root/usr/share/locale/en_US/LC_MESSAGES/backup.po new file mode 100644 index 0000000..800027b --- /dev/null +++ b/root/usr/share/locale/en_US/LC_MESSAGES/backup.po @@ -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 \n" +"Language-Team: LANGUAGE \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 "" diff --git a/root/usr/share/perl5/vendor_perl/esmith/Backup.pm b/root/usr/share/perl5/vendor_perl/esmith/Backup.pm new file mode 100644 index 0000000..82c9cfa --- /dev/null +++ b/root/usr/share/perl5/vendor_perl/esmith/Backup.pm @@ -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 () { + + #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 + +=head1 SEE ALSO + +=cut + +1; diff --git a/root/usr/share/perl5/vendor_perl/esmith/BackupHistoryDB.pm b/root/usr/share/perl5/vendor_perl/esmith/BackupHistoryDB.pm new file mode 100644 index 0000000..0317329 --- /dev/null +++ b/root/usr/share/perl5/vendor_perl/esmith/BackupHistoryDB.pm @@ -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 + +=head1 SEE ALSO + +L + +L + +=cut + +1; diff --git a/root/usr/share/perl5/vendor_perl/esmith/BlockDevices.pm b/root/usr/share/perl5/vendor_perl/esmith/BlockDevices.pm new file mode 100644 index 0000000..4ce2307 --- /dev/null +++ b/root/usr/share/perl5/vendor_perl/esmith/BlockDevices.pm @@ -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; diff --git a/root/usr/share/perl5/vendor_perl/esmith/console/backup_running.pm b/root/usr/share/perl5/vendor_perl/esmith/console/backup_running.pm new file mode 100644 index 0000000..8d304a5 --- /dev/null +++ b/root/usr/share/perl5/vendor_perl/esmith/console/backup_running.pm @@ -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; + diff --git a/root/usr/share/perl5/vendor_perl/esmith/console/perform_backup.pm b/root/usr/share/perl5/vendor_perl/esmith/console/perform_backup.pm new file mode 100644 index 0000000..da6d0b4 --- /dev/null +++ b/root/usr/share/perl5/vendor_perl/esmith/console/perform_backup.pm @@ -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 () + { + 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; diff --git a/root/usr/share/perl5/vendor_perl/esmith/console/perform_restore.pm b/root/usr/share/perl5/vendor_perl/esmith/console/perform_restore.pm new file mode 100644 index 0000000..721bf06 --- /dev/null +++ b/root/usr/share/perl5/vendor_perl/esmith/console/perform_restore.pm @@ -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; + diff --git a/root/var/cache/e-smith/restore/etc/samba/.gitignore b/root/var/cache/e-smith/restore/etc/samba/.gitignore new file mode 100644 index 0000000..e69de29