initial commit of file from CVS for smeserver-affa on Tue 10 Sep 11:19:50 BST 2024

This commit is contained in:
2024-09-10 11:19:50 +01:00
parent 07b7b1b0d7
commit 5b2d8417a7
42 changed files with 7432 additions and 2 deletions

View File

@@ -0,0 +1,5 @@
[GlobalAffaConfig]
sendStatus=weekly
globalStatus=jobs
EmailAddress=root
status=enabled

View File

@@ -0,0 +1,22 @@
[localhost]
remoteHostName=localhost
Include=/root
Include=/etc/affa
ConnectionCheckTimeout=120
Debug=no
Description=Testjob localhost backup
DiskSpaceWarn=strict
RootDir=/var/affa
TimeSchedule=0215
dailyKeep=7
localNice=15
monthlyKeep=12
remoteNice=15
rsync--inplace=yes
rsyncCompress=no
rsyncTimeout=900
scheduledKeep=1
sshPort=22
weeklyKeep=4
yearlyKeep=1
status=disabled

View File

@@ -0,0 +1,5 @@
[samplejob]
remoteHostName=192.168.1.100
sshPort=22
Include=/root
Include=/home

View File

@@ -0,0 +1,22 @@
[SME_SME]
remoteHostName=IP_SME_to_backup
SMEServer=yes
Watchdog=yes
RPMCheck=yes
ConnectionCheckTimeout=120
Debug=no
Description=Testjob bckup of a SME by a SME
DiskSpaceWarn=strict
RootDir=/var/affa
TimeSchedule=0215
localNice=15
remoteNice=15
rsync--inplace=yes
rsyncCompress=no
rsyncTimeout=900
scheduledKeep=1
dailyKeep=7
weeklyKeep=4
monthlyKeep=12
yearlyKeep=1
status=enabled

View File

@@ -0,0 +1,25 @@
[SME_SME]
remoteHostName=IP_SME_to_backup
SMEServer=yes
Watchdog=yes
RPMCheck=yes
ConnectionCheckTimeout=120
Debug=no
Description=Testjob backup of a SME on the usb hard-drive of a SME
DiskSpaceWarn=strict
RootDir=/mnt/hard_drive
AutomountDevice=/dev/sdc1
AutomountPoint=/mnt/hard_drive
AutoUnmount=yes
TimeSchedule=0215
localNice=15
remoteNice=15
rsync--inplace=yes
rsyncCompress=no
rsyncTimeout=900
scheduledKeep=1
dailyKeep=7
weeklyKeep=4
monthlyKeep=12
yearlyKeep=1
status=enabled

View File

@@ -0,0 +1,22 @@
[localSME]
remoteHostName=localhost
SMEServer=yes
Watchdog=yes
ConnectionCheckTimeout=120
Debug=no
Description=Testjob localhost for SME comlete configuration
DiskSpaceWarn=strict
RootDir=/var/affa
TimeSchedule=0215
localNice=15
remoteNice=15
rsync--inplace=yes
rsyncCompress=no
rsyncTimeout=900
scheduledKeep=1
sshPort=22
dailyKeep=7
weeklyKeep=4
monthlyKeep=12
yearlyKeep=1
status=enabled

View File

@@ -0,0 +1,8 @@
[localSME]
remoteHostName=localhost
SMEServer=yes
Watchdog=yes
Description=Testjob localhost for SME minimal configuration
RootDir=/var/affa
TimeSchedule=0215

View File

@@ -0,0 +1,14 @@
#!/usr/bin/perl
use esmith::Backup;
my $b = new esmith::Backup or die 'Error';
my @list = $b->restore_list;
foreach my $dir (@list){
$dir = "/$dir";
push (@newList, $dir);
}
print (join ',', @newList);
exit;

View File

@@ -0,0 +1,5 @@
#!/bin/bash
VALUE=$(/usr/bin/perl -w /tmp/backupList.pl)
echo $VALUE

View File

@@ -0,0 +1,3 @@
#!/bin/sh
/sbin/e-smith/signal-event post-backup

View File

@@ -0,0 +1,3 @@
#!/bin/sh
/sbin/e-smith/signal-event post-upgrade
/sbin/e-smith/signal-event reboot

View File

@@ -0,0 +1,3 @@
#!/bin/sh
/sbin/e-smith/signal-event pre-backup desktop

View File

@@ -0,0 +1,2 @@
#!/bin/sh
/sbin/e-smith/signal-event pre-restore desktop

View File

@@ -0,0 +1,10 @@
#!/bin/sh
mkdir -p /tmp/MySQL-Dumps
chmod 700 /tmp/MySQL-Dumps
for db in $(mysql -BNre "show databases;")
do
mysqldump --add-drop-table --single-transaction -QB "$db" -r /tmp/MySQL-Dumps/"$db".dump || exit 1
chmod 400 /tmp/MySQL-Dumps/"$db".dump
done
exit 0

View File

@@ -0,0 +1,14 @@
#!/usr/bin/perl -w
use strict;
(my $hostname, my $job, my $sshCmd) = @ARGV;
# output is written to the log
print "postJobCommand script postscript-sample.pl\n";
print "hostname=$hostname\n";
print "job=$job\n";
print "sshCmd=$sshCmd\n";
system("$sshCmd $hostname df");
exit 0;

View File

@@ -0,0 +1,13 @@
#!/usr/bin/perl -w
use strict;
(my $hostname, my $job) = @ARGV;
# output is written to the log
print "postJobCommandRemote script postscriptRemote-sample.pl\n";
print "hostname=$hostname\n";
print "job=$job\n";
system("df");
exit 0;

View File

@@ -0,0 +1,14 @@
#!/usr/bin/perl -w
use strict;
(my $hostname, my $job, my $sshCmd) = @ARGV;
# output is written to the log
print "preJobCommand script prescript-sample.pl\n";
print "hostname=$hostname\n";
print "job=$job\n";
print "sshCmd=$sshCmd\n";
system("$sshCmd $hostname ls -l /var");
exit 0;

View File

@@ -0,0 +1,13 @@
#!/usr/bin/perl -w
use strict;
(my $hostname, my $job) = @ARGV;
# output is written to the log
print "preJobCommandRemote script prescriptRemote-sample.pl\n";
print "hostname=$hostname\n";
print "job=$job\n";
system("ls -l /var");
exit 0;

View File

@@ -0,0 +1,5 @@
#!/bin/sh
mkdir -p /tmp/yum-install
echo -n "yum install " > /tmp/yum-install/install_all.$$
yum list installed |grep -v "^ "|sed -e 's/ .*//' | grep "\."| sed -e 's/\..*//' | tr '\n' ' ' >> /tmp/yum-install/install_all.$$
mv /tmp/yum-install/install_all.$$ /tmp/yum-install/install_all

1
root/etc/cron.d/affa Normal file
View File

@@ -0,0 +1 @@
*/15 * * * * root /sbin/affa --_cronupdate

View File

@@ -0,0 +1,3 @@
# WARNING: don't remove the # of the following section!
#[Affa-jobs]

View File

@@ -0,0 +1,5 @@
/var/log/affa/*.log {
weekly
rotate 5
missingok
}

20
root/etc/profile.d/affa.sh Executable file
View File

@@ -0,0 +1,20 @@
function _affa()
{
local cur; cur=${COMP_WORDS[$COMP_CWORD]}
case $COMP_CWORD in
# option
1)
COMPREPLY=( $(/sbin/affa --_shorthelp | grep " affa $cur"|awk '{print $3}' ) )
;;
# job
2)
/sbin/affa --_shorthelp | grep -qs -- "${COMP_WORDS[1]}.*JOB"
if [ "$?" == 0 ] ; then
COMPREPLY=( $(/sbin/affa --_jobs | grep "^$cur" ) )
fi
;;
esac
return 0
}
complete -F _affa affa

2
root/etc/sudoers.d/affa Normal file
View File

@@ -0,0 +1,2 @@
Defaults:nagios !requiretty
nagios ALL=(ALL) NOPASSWD: /sbin/affa

5264
root/sbin/affa Normal file

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,14 @@
#!/bin/bash
#
# This script is part of the smeserver-affa package
# Copyright (C) 2008 Michael Weinberger, neddix Stuttgart, Germany
#
#/usr/bin/yum --noplugins list installed\
#|/bin/grep "installed *$"\
#|/bin/sed -e 's/\./ /'\
#|/bin/awk '{printf "%s %s\n", $1,$3}'
#
# Fixing bug 9270: RPMCheck for SME9
/bin/rpm -qa --qf "%{NAME} %{VERSION}-%{RELEASE}\n" | sort -fu

2
root/sbin/resume-affa-jobs Executable file
View File

@@ -0,0 +1,2 @@
#!/bin/sh
/sbin/affa --resume-interrupted

View File

@@ -0,0 +1,67 @@
#!/usr/bin/perl -wT
#----------------------------------------------------------------------
# affa watchdog testmail
#
# This script is part of the smeserver-affa package
#
# Copyright (C) 2008 Michael Weinberger, neddix Stuttgart, Germany
#
# 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
#
#----------------------------------------------------------------------
use strict;
use Errno;
use esmith::DB::db;
use esmith::ConfigDB;
use File::Path;
use Mail::Send;
use constant _JOBNAME=>'nx scheduled';
use constant _EMAIL=>'mweinber@neddix.de';
use constant _BACKUPHOST=>'backup.neddix.de (172.22.32.2)';
use constant _WDSCRIPT=>'affa-watchdog-nx-172.22.32.6';
BEGIN
{
# Clear PATH and related environment variables so that calls to
# external programs do not cause results to be tainted. See
# "perlsec" manual page for details.
$ENV {'BASH_ENV'} = '';
$ENV {'PATH'} = '';
}
sub sendEmail();
sendEmail();
unlink( "/tmp/".(_WDSCRIPT) );
exit 0;
sub sendEmail()
{
my $config = esmith::ConfigDB->open_ro or die "Could not open config db.";
my $LocalIP=$config->get("LocalIP")->value;
my $SystemName=$config->get("SystemName")->value;
my $DomainName=$config->get("DomainName")->value;
my $msg = new Mail::Send;
$msg->subject("Testmail for affa job '".(_JOBNAME)."' on ".(_BACKUPHOST)."");
$msg->to(_EMAIL);
$msg->set("From", "\"Affa watchdog on $SystemName.$DomainName ($LocalIP)\" <noreply\@$SystemName.$DomainName>");
my $fh = $msg->open;
print $fh "It works!\n";
$fh->close;
}

View File

@@ -0,0 +1,90 @@
#!/usr/bin/perl -wT
#----------------------------------------------------------------------
# affa watchdog
#
# This script is part of the smeserver-affa package
#
# Copyright (C) 2008 Michael Weinberger, neddix Stuttgart, Germany
#
# 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
#
#----------------------------------------------------------------------
use strict;
use Errno;
use esmith::DB::db;
use esmith::ConfigDB;
use Date::Format;
use File::Path;
use Mail::Send;
use constant _TRIGGER=>200703281100;
use constant _JOBNAME=>'nx scheduled';
use constant _EMAIL=>'mweinber@neddix.de';
use constant _BACKUPHOST=>'backup.neddix.de (172.22.32.2)';
use constant _SCHEDULED=>'Wed Mar 28 13:10:14 2007';
use constant _WDSCRIPT=>'affa-watchdog-nx-172.22.32.6';
BEGIN
{
# Clear PATH and related environment variables so that calls to
# external programs do not cause results to be tainted. See
# "perlsec" manual page for details.
$ENV {'BASH_ENV'} = '';
$ENV {'PATH'} = '';
}
sub sendEmail($);
my $now = Date::Format::time2str("%Y%m%d%H%M",time());
my $nowHour = int(Date::Format::time2str("%k",time()));
exit 0 if( $now<(_TRIGGER) );
(my $Reminder = (_TRIGGER)) =~ s/........(..)../$1/;
$Reminder=int($Reminder);
if( -f "/etc/cron.hourly/".(_WDSCRIPT) ) # send the first warning
{
sendEmail('');
rename( "/etc/cron.hourly/".(_WDSCRIPT), "/etc/cron.hourly/".(_WDSCRIPT)."-reminder" );
}
elsif( $now-(_TRIGGER) > 1200 and $nowHour==$Reminder ) # send daily reminder
{
sendEmail(' (Reminder) ');
}
exit 0;
sub sendEmail($)
{
my $config = esmith::ConfigDB->open_ro or die "Could not open config db.";
my $LocalIP=$config->get("LocalIP")->value;
my $SystemName=$config->get("SystemName")->value;
my $DomainName=$config->get("DomainName")->value;
my $reminder=shift(@_);
my $msg = new Mail::Send;
$msg->subject("Error: ".$reminder."Scheduled affa job '".(_JOBNAME)."' did not run on ".(_BACKUPHOST)."");
$msg->to(_EMAIL);
$msg->set("From", "\"Affa watchdog on $SystemName.$DomainName ($LocalIP)\" <noreply\@$SystemName.$DomainName>");
my $fh = $msg->open;
print $fh "The backup job '".(_JOBNAME)."' scheduled on ".(_SCHEDULED)." did not run.\n";
print $fh "Please check and fix your affa configuration on ".(_BACKUPHOST).".\n";
print $fh "A reminder message will be sent at $Reminder:00 hours, if the error continues unchecked.\n\n";
print $fh "Remove the file /etc/cron.hourly/".(_WDSCRIPT)."-reminder to stop receiving reminder messages.\n";
$fh->close;
}

Binary file not shown.

0
root/var/lock/affa/.gitignore vendored Normal file
View File

0
root/var/log/affa/.gitignore vendored Normal file
View File