initial commit of file from CVS for smeserver-BackupPC on Sat Sep 7 20:10:07 AEST 2024

This commit is contained in:
Trevor Batley
2024-09-07 20:10:07 +10:00
parent 2bf47720f7
commit 26a891845f
51 changed files with 2421 additions and 2 deletions

View File

@@ -0,0 +1,67 @@
#!/usr/bin/perl
# Author: Daniel Berteaud (daniel@firewall-services.com)
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
use lib "/usr/share/BackupPC/lib";
use BackupPC::SMEarchive;
use strict;
my $logFile = '/tmp/'.genRandName ();
# Sortie erreur standard=fichier de log
open (STDERR, ">$logFile");
my $today = `$path{date} +%F-%kh%M`;
my $check = 1;
# on inscrit la date en haut du fichier log
print STDERR "Starting archive: ".`$path{date}`."\n";
my %opts=();
my %params=(
'destination'=>"/tmp/",
'split'=>"0",
'compress'=>"gzip",
'cipher'=>'off',
'key'=>'/etc/BackupPC/archive.key',
'backupNum'=>"-1",
'share'=>"*",
'parity'=>'0',
'hosts'=>'localhost',
'sendMailTo'=>'admin',
'configFile'=>'/etc/BackupPC/localArchive.conf');
# On lance la récupération des paramètre qui retourne le fichier de config à utiliser
$params{configFile} = init($params{configFile});
%params = readConf(\%params);
print STDERR "\nYou have requested to archive these hosts: $params{hosts} to this destination: $params{destination}\n\n";
localArchive($params{hosts},$params{backupNum},$params{share},$params{compress},$params{split},$params{cipher},$params{key},$params{destination});
print STDERR "\n\nArchive finished: ".`$path{date}`."\n";
my $log = `$path{cat} $logFile`;
sendMail($params{sendMailTo},'localArchive',$log);
mvLog('localArchive',$logFile,$today);
exit(0);

View File

@@ -0,0 +1,80 @@
#!/usr/bin/perl
# Author: Daniel Berteaud (daniel@firewall-services.com)
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
use lib "/usr/share/BackupPC/lib";
use BackupPC::SMEarchive;
use BackupPC::SMEcopyPool;
use strict;
my $logFile = '/tmp/'.genRandName ();
my $rsyncLog = '/tmp/'.genRandName ();
my $check = 1;
# Sortie erreur standard=fichier de log
open (STDERR, ">$logFile");
my $today = `$path{date} +%F-%kh%M`;
# on inscrit la date en haut du fichier log
print STDERR "Starting pool copy: ".`$path{date}`."\n";
my %opts=();
my %params=(
'destination'=>"/tmp/",
'source'=>'/var/lib/BackupPC/',
'compress'=>"gzip",
'extract'=>"yes",
'stop'=>"yes",
'sendMailTo'=>'admin',
'configFile'=>'/etc/BackupPC/localCopyPool.conf');
# On lance la récupération des paramètres qui retourne le fichier de config à utiliser
$params{configFile} = init($params{configFile});
%params = readConf(\%params);
print STDERR "You have requested to copy all your backups ($params{source}) to this destination: $params{destination}\n\n";
$check = verifTree($params{source});
if ($check eq 1){
if ($params{stop} eq 'yes'){
stopBackupPC();
}
copyPool($params{source},$params{destination},$logFile,$rsyncLog);
localCopyPC($params{source},$params{destination},$params{compress},$params{extract},$logFile);
if ($params{stop} eq 'yes'){
startBackupPC();
}
}
else{
print STDERR "\naborting, the source directory is probably not the good one\n\n";
}
print STDERR "\n\nCopy finished: ".`$path{date}`."\n";
my $log = `$path{cat} $logFile`;
sendMail($params{sendMailTo},'localCopyPool',$log);
mvLog('localCopyPool',$logFile,$today);
exit(0);

View File

@@ -0,0 +1,13 @@
#!/bin/bash
HOME=/root
PATH=/usr/bin:$PATH
# Backup config and log on the dedicated hard drive
mkdir -p /var/lib/BackupPC/etc
rsync -ahq --del /etc/BackupPC/ /var/lib/BackupPC/etc/
mkdir -p /var/lib/BackupPC/log
rsync -ahq --del /var/log/BackupPC /var/lib/BackupPC/log/
# Run a standard signal-event pre-backup
/sbin/e-smith/signal-event pre-backup

View File

@@ -0,0 +1,67 @@
#!/usr/bin/perl
# Author: Daniel Berteaud (daniel@firewall-services.com)
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
use lib "/usr/share/BackupPC/lib";
use BackupPC::SMEarchive;
use strict;
my $logFile = '/tmp/'.genRandName ();
# Sortie erreur standard=fichier de log
open (STDERR, ">$logFile");
my $today = `$path{date} +%F-%kh%M`;
my $check = 1;
# on inscrit la date en haut du fichier log
print STDERR "Starting archive: ".`$path{date}`."\n";
my %opts=();
my %params=(
'remoteHost'=>"remote_host.com",
'remoteUser'=>"backuppc",
'remoteDir'=>"/tmp/",
'compress'=>"gzip",
'cipher'=>'off',
'key'=>'/etc/BackupPC/archive.key',
'backupNum'=>"-1",
'share'=>"*",
'hosts'=>'localhost',
'sendMailTo'=>'admin',
'configFile'=>'/etc/BackupPC/remoteArchive.conf');
# On lance la récupération des paramètre qui retourne le fichier de config à utiliser
$params{configFile} = init($params{configFile});
%params = readConf(\%params);
print STDERR "\nYou have requested to archive these hosts: $params{hosts} to this destination: $params{remoteUser}\@$params{remoteHost}:/$params{remoteDir}\n\n";
remoteArchive($params{remoteHost},$params{remoteUser},$params{remoteDir},$params{hosts},$params{backupNum},$params{share},$params{compress},$params{cipher},$params{key});
print STDERR "\n\nArchive finished: ".`$path{date}`."\n";
my $log = `$path{cat} $logFile`;
sendMail($params{sendMailTo},'remoteArchive',$log);
mvLog('remoteArchive',$logFile,$today);
exit(0);

View File

@@ -0,0 +1,84 @@
#!/usr/bin/perl
# Author: Daniel Berteaud (daniel@firewall-services.com)
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
use lib "/usr/share/BackupPC/lib";
use BackupPC::SMEarchive;
use BackupPC::SMEcopyPool;
use strict;
my $logFile = '/tmp/'.genRandName ();
my $rsyncLog = '/tmp/'.genRandName ();
my $check = 1;
# Sortie erreur standard=fichier de log
open (STDERR, ">$logFile");
my $today = `$path{date} +%F-%kh%M`;
# on inscrit la date en haut du fichier log
print STDERR "Starting pool copy: ".`$path{date}`."\n";
my %opts=();
my %params=(
'remoteHost'=>"remote_host.com",
'remoteUser'=>"backuppc",
'remoteDir'=>"/tmp/",
'source'=>'/var/lib/BackupPC/',
'compress'=>"gzip",
'extract'=>"yes",
'stop'=>"yes",
'sendMailTo'=>'admin',
'configFile'=>'/etc/BackupPC/remoteCopyPool.conf');
# On lance la récupération des paramètres qui retourne le fichier de config à utiliser
$params{configFile} = init($params{configFile});
%params = readConf(\%params);
print STDERR "You have requested to copy all your backups ($params{source}) to this destination: $params{remoteUser}\@$params{remoteHost}:$params{remoteDir}\n\n";
$check = verifTree($params{source});
if ($check eq 1){
if ($params{stop} eq 'yes'){
stopBackupPC();
}
copyPool($params{source},"$params{remoteUser}\@$params{remoteHost}:$params{remoteDir}",$logFile,$rsyncLog);
remoteCopyPC($params{source},$params{remoteHost},$params{remoteUser},$params{remoteDir},$params{compress},$params{extract},$logFile);
if ($params{stop} eq 'yes'){
startBackupPC();
}
}
else{
print STDERR "\naborting, the source directory is probably not the good one\n\n";
}
print STDERR "\n\nCopy finished: ".`$path{date}`."\n";
my $log = `$path{cat} $logFile`;
sendMail($params{sendMailTo},'remoteCopyPool',$log);
mvLog('remoteCopyPool',$logFile,$today);
exit(0);

View File

@@ -0,0 +1,85 @@
#!/usr/bin/perl
# Author: Daniel Berteaud (daniel@firewall-services.com)
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
use lib "/usr/share/BackupPC/lib";
use BackupPC::SMEarchive;
#use Getopt::Std;
use strict;
my $logFile = '/tmp/'.genRandName ();
# Sortie erreur standard=fichier de log
open (STDERR, ">$logFile");
my $today = `$path{date} +%F-%kh%M`;
my $check = 1;
# on inscrit la date en haut du fichier log
print STDERR "Starting archive: ".`$path{date}`."\n";
my %opts=();
my %params=(
'split'=>"0",
'compress'=>"/bin/gzip",
'cipher'=>'off',
'key'=>'/etc/BackupPC/archive.key',
'backupNum'=>"-1",
'share'=>"*",
'hosts'=>'localhost',
'sendMailTo'=>'admin',
'device'=>'/dev/sdc1',
'configFile'=>'/etc/BackupPC/usbArchive.conf');
# On définit un nom aléatoire pour le point de montage
$params{destination} = '/var/lib/BackupPC/'.genRandName();
# On lance la récupération des paramètre qui retourne le fichier de config à utiliser
$params{configFile} = init($params{configFile});
%params = readConf(\%params);
print STDERR "\nYou have requested to archive these hosts: $params{hosts} to this destination: $params{destination}\n\n";
$check = mountUsb($params{destination},$params{device});
if ($check eq 1){
localArchive($params{hosts},$params{backupNum},$params{share},$params{compress},$params{split},$params{cipher},$params{key},$params{destination});
}
else{
print STDERR "\n\nAborting, an error occured while mounting the removable device $params{device} on $params{destination}\n\n";
}
$check = umountUsb($params{destination},$params{device});
if ($check = 1){
print STDERR "\numounting $params{device}: [ OK ]\n";
}
else{
print STDERR "\nan error occured while unmounting the device $params{device} from $params{destination}\n";
}
print STDERR "\n\nArchive finished: ".`$path{date}`."\n";
my $log = `$path{cat} $logFile`;
sendMail($params{sendMailTo},'usbArchive',$log);
mvLog('usbArchive',$logFile,$today);
exit(0);

View File

@@ -0,0 +1,93 @@
#!/usr/bin/perl
# Author: Daniel Berteaud (daniel@firewall-services.com)
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
use lib "/usr/share/BackupPC/lib";
use BackupPC::SMEarchive;
use BackupPC::SMEcopyPool;
use strict;
my $logFile = '/tmp/'.genRandName ();
my $rsyncLog = '/tmp/'.genRandName ();
my $check = 1;
# Sortie erreur standard=fichier de log
open (STDERR, ">$logFile");
my $today = `$path{date} +%F-%kh%M`;
# on inscrit la date en haut du fichier log
print STDERR "Starting pool copy: ".`$path{date}`."\n";
my %opts=();
my %params=(
'device'=>'/dev/sdc1',
'source'=>'/var/lib/BackupPC',
'compress'=>"none",
'extract'=>"yes",
'stop'=>"yes",
'sendMailTo'=>'admin',
'configFile'=>'/etc/BackupPC/usbCopyPool.conf');
# On définit un nom aléatoire pour le point de montage
$params{destination} = '/var/lib/BackupPC/'.genRandName();
# On lance la récupération des paramètres qui retourne le fichier de config à utiliser
$params{configFile} = init($params{configFile});
%params = readConf(\%params);
print STDERR "You have requested to copy all your backups ($params{source}) to this destination: $params{device}\n\n";
$check = (verifTree($params{source}) && mountUsb($params{destination},$params{device}));;
if ($check eq 1){
if ($params{stop} eq 'yes'){
stopBackupPC();
}
copyPool($params{source},$params{destination},$logFile,$rsyncLog);
localCopyPC($params{source},$params{destination},$params{compress},$params{extract},$logFile);
if ($params{stop} eq 'yes'){
startBackupPC();
}
}
else{
print STDERR "\naborting, the source directory is probably not the good one, or an error occured while mounting $params{device} on $params{destination}\n\n";
}
$check = umountUsb($params{destination},$params{device});
if ($check = 1){
print STDERR "\numounting $params{device}: [ OK ]\n";
}
else{
print STDERR "\nan error occured while unmounting the device $params{device} from $params{destination}\n";
}
print STDERR "\n\nCopy finished: ".`$path{date}`."\n";
my $log = `$path{cat} $logFile`;
sendMail($params{sendMailTo},'usbCopyPool',$log);
mvLog('usblCopyPool',$logFile,$today);
exit(0);