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