Redmine backup onto a bup remote server

This script can be used to backup a dockerized Redmine instance onto a bup remote server. I have since migrated to restic but this script can still be used

Also see Local redmine backup using bup (docker-compose compatible)

#!/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.11.12.15

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 MariaDB
source .env && docker-compose exec -T mariadb mysqldump -uroot -p${MARIADB_ROOT_PASSWORD} --all-databases | bup -d $BUP_DIR split -r $BUP_REMOTE -n $NAME-mariadb.sql
# Save directories
bup_directory redmine_data
bup_directory redmine_themes
# 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 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