Inviare un report al termine di ogni backup di BackupPC

From RVM Wiki
Jump to navigation Jump to search
  • Impostare il comando da eseguire alla fine di ogni backup:
sudoedit /etc/backuppc/config.pl
$Conf{DumpPostUserCmd}    = '/usr/local/bin/BackupPC_DumpPostUserCmd $type $xferOK $client $host $hostIP $user $moreUsers $share $shares $XferMethod $sshPath $cmdType ';
  • Creare lo script
cat | sudo tee /usr/local/bin/BackupPC_DumpPostUserCmd >/dev/null <<'EOFileReal'
#!/bin/bash
type="$1"
xferOK="$2"
client="$3"
host="$4"
hostIP="$5"
user="$6"
moreUsers="$7"
share="$8"
shares="$9"
XferMethod=${10}
sshPath="${11}"
cmdType="${12}"

if [ $xferOK -eq 1 ]
then
        SUBJECT="Backup Succesful of $client"
        MSG=$(cat <<EOFile
The backup of $client was succesfull.

Parameters are:
type=$1
xferOK=$2
client=$3
host=$4
hostIP=$5
user=$6
moreUsers=$7
share=$8
shares=$9
XferMethod=${10}
sshPath=${11}
cmdType=${12}
EOFile
)

else
        SUBJECT="Backup UNSUCCESSFUL of $client"
        MSG=$(cat <<EOFile
The backup of $client was UNSUCCESFUL.

Parameters are:
type=$1
xferOK=$2
client=$3
host=$4
hostIP=$5
user=$6
moreUsers=$7
share=$8
shares=$9
XferMethod=${10}
sshPath=${11}
cmdType=${12}
EOFile
)
fi

echo -e $MSG | mail -s "${SUBJECT}" $moreUsers
EOFileReal
  • Renderlo eseguibile
sudo chmod +x /usr/local/bin/BackupPC_DumpPostUserCmd
  • Riavviare backuppc
sudo invoke-rc.d backuppc restart

Riferimenti