smeserver-BackupPC/root/usr/share/BackupPC/bin/BackupPC_SME_localCopyPool

81 lines
2.3 KiB
Perl
Executable File

#!/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);