InvenTree bup-based backup script
Note: I have replaced the bup-based backup with restic.
Install using How to create a systemd backup timer & service in 10 seconds
Place this file in the same directory as your docker-compose.yml file, and make it executable.
backup.sh
#!/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
# Create backup archives
docker-compose run inventree-server invoke backup
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 PostgreSQL
#docker-compose exec -u gitlab-psql gitlab pg_dump -h /var/opt/gitlab/postgresql/ -d gitlabhq_production | bup -d $BUP_DIR split -r $BUP_REMOTE -n $NAME-pgdump.sql
# Save directories
bup_directory config
bup_directory data
# 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 --unsafeCheck out similar posts by category:
Backup
If this post helped you, please consider buying me a coffee or donating via PayPal to support research & publishing of new posts on TechOverflow