Added the 'crypted' operaton mode, and some more comments v0.2.0
authorRalph Ronnquist <rrq@rrq.au>
Sat, 22 Jun 2024 06:43:55 +0000 (16:43 +1000)
committerRalph Ronnquist <rrq@rrq.au>
Sat, 22 Jun 2024 06:43:55 +0000 (16:43 +1000)
timeliner-cron

index 3159db127ad3ff13575193dad14fdc7b81da9c36..8e52ffce35269fd5a1b0a909cf683ff246b93ea9 100755 (executable)
@@ -6,11 +6,19 @@
 LOCKFILE=/var/lock/timeliner-cron.lock
 LOGFILE="/var/log/timeliner.log"
 
-OPMODE=disabled
-LBASE=/backup
-RBASE=/backup
-REMOTE=backup
-DIRS="/bin /etc /home /opt /root"
+# Which directory trees to back up
+DIRS="/boot /etc /home /opt /root"
+
+# Operations mode: disabled, local, remote, mixed, crypted.
+OPMODE="disabled"
+
+# These are used differently in different modes. See descriptions below
+LBASE="/backfs/vault/myhost"
+REMOTE="backup"
+RBASE="/backfs/vault"
+LHIDE=/backfs/.vault
+LOPEN=/backfs/vault
+LPASS="/root/.ssh/backfs.pass"
 
 exec >>$LOGFILE 2>&1
 
@@ -18,13 +26,32 @@ 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
+       # LBASE is the local root for backup timeline
        timeliner $LBASE $DIRS
        ;;
+    remote) # Remote-only backup scheme
+       # REMOTE identifies remote host
+       # RBASE is the remote root for the backup timeline
+       timeliner $REMOTE:$RBASE $DIRS
+       ;;
     mixed) # Local backup window with remote store
+       # LBASE is the local root for backup timeline
+       # REMOTE identifies remote host
+       # RBASE is the remote root for the backup timeline
        timeliner $LBASE $DIRS && timeliner-backup $REMOTE:$RBASE $LBASE
        ;;
+    crypted) # Local backup into a gocyptfs mount of an sshfs mount
+       # REMOTE identifies remote host
+       # RBASE is the remote root for the encrypted backup store
+       # LHIDE is the local mountpoint for encrypted backup store
+       # LOPEN is the local mountpoint for the opened backup store
+       # LBASE is the local root for the backup timeline
+       # LPASS is the password file for opening the encrypted backup store
+       sshfs $REMOTE:$RBASE $LHIDE &&
+           gocryptfs -extpass "cat $LPASS" $LHIDE $LOPEN &&
+           timeliner $LBASE $DIRS
+       fusermount -u $LOPEN
+       fusermount -u $LHIDE
+       ;;
 esac