cleanup v0.0.1 v0.1.0
authorRalph Ronnquist <rrq@rrq.au>
Sun, 9 Jun 2024 08:21:11 +0000 (18:21 +1000)
committerRalph Ronnquist <rrq@rrq.au>
Sun, 9 Jun 2024 08:21:11 +0000 (18:21 +1000)
Makefile
timeliner-cron [changed mode: 0644->0755]

index 0d06bc8af99296b3be306384315939d6905337b2..9550ee6843baef227b83080f0c7952cf4a8ff924 100644 (file)
--- 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)
old mode 100644 (file)
new mode 100755 (executable)
index 27d7161..3159db1
@@ -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