Select Git revision
tetras-back
tetras-back 14.13 KiB
#!/usr/bin/perl
# Copyright (C) 2017 Tetras Libre <admin@tetras-libre.fr>
# Author: Beniamine, David <David@Beniamine.net>
#
# 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 3 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, see <http://www.gnu.org/licenses/>.
use strict;
use warnings;
use threads ('yield',
'stack_size' => 64*4096,
'exit' => 'threads_only',
'stringify');
use utf8;
use POSIX;
use MIME::Lite;
use IO::Handle;
use Data::Dumper;
use Cpanel::JSON::XS qw(encode_json);
use Log::Dispatch;
use Getopt::ArgParse;
use Try::Tiny;
my $Logger;
my %running_backups;
my $LOGDIR = "/var/log/tetras-back";
my $CFGFILE = "/etc/tetras-back/configuration.pl";
my $MAINFIFO = "/var/run/tetras-back.fifo";
my %MESSAGES = (
0 => {
'status' => 'Sauvegarde réussie',
'message' => "La sauvegarde c'est terminée correctement,
vous pouvez maintenant débrancher le disque dur.",
},
1 => {
'status' => 'Echec de la sauvegarde',
'message' => "La sauvegarde c'est terminée avec au moins une erreur et
est donc probablement incomplète, avez vous arraché le disque pendant
la sauvegarde ? Essayez de débrancher et rebrancher le disque, si
l'erreur persiste contactez vos administrateur.ice.s système au plus
vite",
},
2 => {
'status' => 'Arrachage pendant la sauvegarde',
'message' => "La sauvegarde est probablement corrompue, veuillez
rebancher le disque dès que possible",
},
);
# Read/SaveCfg snippet from
# http://www.perlmonks.org/?displaytype=print;node_id=464358
# Read a configuration file
# The arg can be a relative or full path, or
# it can be a file located somewhere in @INC.
sub ReadCfg{
my $file = $_[0];
our $err;