Thursday, July 30, 2020

all my pies backup critical files

cron has the following entry

20 3 * * * /usr/sbin/netdate cp1 >> /home/netdate/n3.netdate.log
10  3 3 * * /root/bin/backupnode.sh >> /var/log/backupnode.log

which runs the following.

root@nas3:~/bin# cat backupnode.sh
#!/bin/bash
START=`/bin/date +%s`
CP="/bin/cp -Ru"
DATE=$(/usr/bin/date +%m%d%y-%H%M%S)
ECHO=/usr/bin/echo
AWK=/usr/bin/awk
CAT=/usr/bin/cat
HOSTNAME=/etc/HOSTNAME
HOST=`$CAT $HOSTNAME | $AWK 'BEGIN { FS = "."} ; { print $1 }'`
LOG="/home/zero/systems/$HOST.log"
LLOG="/var/log/system-backup.log"
ZERODIR="/home/zero/systems/$HOST/"
BACKUPDIRS="/root /etc /srv/httpd/htdocs /usr/spool/cron/crontabs"
#
#  System Files
#
for DIR in $BACKUPDIRS
  do
    $CP $DIR $ZERODIR
  done

END=`/bin/date +%s`
RUNTIME=$((END-START))
$ECHO "$DATE - Runtime = $RUNTIME" >> $LOG
$ECHO "$DATE - Runtime = $RUNTIME" >> $LLOG