Backup up UptimeKuma using bup remote

This is my bup script to backup UptimeKuma to a bup remote server. It’s based on the 2-minute UptimeKuma setup using Traefik & docker-compose (self-hosted UptimeRobot alternative) post for the docker-compose setup.

I have since migrated to Restic, but this script can still be used.

#!/bin/bash
export NAME=$(basename $(pwd))
export BUP_DIR=/var/bup/$NAME.bup
export REMOTE_BUP_DIR=/bup-backups/$NAME.bup
export REMOTE_SERVER=10.1.2.3
export BUP_REMOTE=$REMOTE_SERVER:$REMOTE_BUP_DIR

bup_directory() {
        echo "BUPing $1"
        bup -d $BUP_DIR index $1 && bup -d $BUP_DIR save -r $BUP_REMOTE -9 --strip-path $(pwd) -n $1 $1
}
# Init
bup -d $BUP_DIR init -r $BUP_REMOTE
# Save UptimeKuma
source .env && docker-compose exec -T kuma sqlite3 /app/data/kuma.db .dump | bup -d $BUP_DIR split -r $BUP_REMOTE -n $NAME-sqlite.sql
# Backup self
bup_directory backup.sh
bup_directory docker-compose.yml
# OPTIONAL: Add par2 information
#   This is only recommended for backup on unreliable storage or for extremely critical backups
#   If you already have bitrot protection (like BTRFS with regular scrubbing), this might be overkill.
# Uncomment this line to enable:
# bup fsck -g

# bup on $REMOTE_SERVER -d $REMOTE_BUP_DIR fsck -g

# OPTIONAL: Cleanup old backups
bup on $REMOTE_SERVER -d $REMOTE_BUP_DIR prune-older --keep-all-for 1m --keep-dailies-for 6m --keep-monthlies-for forever -9 --unsafe