From 518664eb63d646222e372a1e68a13ca466ff3809 Mon Sep 17 00:00:00 2001 From: Ralph Ronnquist Date: Sun, 9 Jun 2024 18:21:11 +1000 Subject: [PATCH] cleanup --- Makefile | 9 +++++++-- timeliner-cron | 33 +++++++++++++++++++++++---------- 2 files changed, 30 insertions(+), 12 deletions(-) mode change 100644 => 100755 timeliner-cron diff --git a/Makefile b/Makefile index 0d06bc8..9550ee6 100644 --- a/Makefile +++ b/Makefile @@ -1,7 +1,12 @@ MANPAGES = $(basename $(wildcard *.8.adoc)) -$(warning MANPAGES = $(MANPAGES)) -all: $(MANPAGES) +all: $(MANPAGES:=.gz) %.8: %.8.adoc asciidoctor -bmanpage $< + +%.8.gz: %.8 + gzip $< + +clean: + rm -f $(MANPAGES) $(MANPAGES:=.gz) diff --git a/timeliner-cron b/timeliner-cron old mode 100644 new mode 100755 index 27d7161..3159db1 --- a/timeliner-cron +++ b/timeliner-cron @@ -3,15 +3,28 @@ # This is intended to be installed as a cron.hourly script. # -#LOGFILE=/var/log/timeliner.log -#LOCAL=/backup -#BASE=/backup -#REMOTE=remote.example.com # needs paswwordless ssh access to root -#DIRS="/root /etc /home /opt /usr" +LOCKFILE=/var/lock/timeliner-cron.lock +LOGFILE="/var/log/timeliner.log" -[ -z "$DIRS" ] && exit 0 # "not configured yet" +OPMODE=disabled +LBASE=/backup +RBASE=/backup +REMOTE=backup +DIRS="/bin /etc /home /opt /root" -{ - flock -n 1 || exit 0 - timeliner $LOCAL $DIRS && timeliner-backup $REMOTE:$BASE $LOCAL -} >> $LOGFILE 2>&1 +exec >>$LOGFILE 2>&1 + +exec 9>$LOCKFILE +flock -n 9 || exit 0 + +case "$OPMODE" in + remote) # Remote-only backup scheme + timeliner $REMOTE:$RBASE $DIRS + ;; + local) # Local-only backup scheme + timeliner $LBASE $DIRS + ;; + mixed) # Local backup window with remote store + timeliner $LBASE $DIRS && timeliner-backup $REMOTE:$RBASE $LBASE + ;; +esac -- 2.39.5