"Fossies" - the Fresh Open Source Software Archive

Member "rsync-backup-0.11/rsync-backup-wrapper.sh" (22 Dec 2020, 923 Bytes) of package /linux/privat/rsync-backup-0.11.tar.bz2:


As a special service "Fossies" has tried to format the requested source page into HTML format using (guessed) Bash source code syntax highlighting (style: standard) with prefixed line numbers and code folding option. Alternatively you can here view or download the uninterpreted source code file.

    1 #!/bin/bash
    2 exec 2>&1
    3 
    4 if [ ! -f "/etc/rsync-backup.conf" ]
    5 then
    6     echo "No configuration file found in /etc/rsync-backup.conf. Exiting..."
    7     exit 1
    8 fi
    9 
   10 source "/etc/rsync-backup.conf"
   11 
   12 LOG="/var/log/backup/backup-`date +%Y-%m-%d_%H-%M-%S`.log"
   13 mkdir -p `dirname ${LOG}`
   14 if [ -e $LOG ]; then
   15     echo "Log already exists, cannot continue."
   16     exit 1
   17 else
   18     touch ${LOG}
   19 fi
   20 `dirname $0`/rsync-backup.sh > ${LOG}
   21 exitcode=$?
   22 
   23 scp -qP ${SSHPORT} ${LOG} ${DESTHOST}:${DESTDIR}/daily.1/backup.log
   24 if [ $exitcode -eq 0 ]; then
   25     echo -e "${NAGIOS_HOSTNAME}\t${NAGIOS_SERVICE}\t0\tRsync backup returned OK\n" | /usr/bin/send_nsca -H ${NAGIOS_NSCAHOST} -c /etc/nagios/send_nsca.cfg >/dev/null
   26 else
   27     echo -e "${NAGIOS_HOSTNAME}\t${NAGIOS_SERVICE}\t2\tRsync backup returned ERROR: ${exitcode}\n" | /usr/bin/send_nsca -H ${NAGIOS_NSCAHOST} -c /etc/nagios/send_nsca.cfg >/dev/null
   28     mail -s "Cron <`hostname`> backup" ${ERROR_MAIL} < ${LOG}
   29 fi
   30