68 lines
2.1 KiB
Plaintext
68 lines
2.1 KiB
Plaintext
|
#!/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);
|
||
|
|