diff --git a/docker-compose.yml b/docker-compose.yml index 4bec10f..5f4b028 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -26,9 +26,10 @@ services: # Used for determining the health of the container - MAX_BACKUP_AGE_SECONDS=86400 # default: 86400 (1d) volumes: - - /volumes:/source:ro # we backup this folder (which is a BTRFS volume), we mustn't change it, so it's readonly + - /:/btrfs-root:ro - /volumes/backup:/snapshot # we must mount a path to a folder on the BTRFS disk for the snapshot to be put at, this is just a temporary path - /volumes/backup/logs:/backup-logs # we will store the output of the backup commands in this folder + - borg-cache:/root/.cache/borg # speed up subsequent backups - health-flag:/health # this is used to determine if the backup was successful and when it was last run diff --git a/src/backup.sh b/src/backup.sh index 67f62f1..bf75561 100755 --- a/src/backup.sh +++ b/src/backup.sh @@ -23,13 +23,13 @@ fi # we want to stop the script immediately. set -e -if [ -d "/snapshot/source" ]; then - btrfs subvolume delete /snapshot/source +if [ -d "/snapshot/btrfs-root" ]; then + btrfs subvolume delete /snapshot/btrfs-root fi -btrfs subvolume snapshot /source /snapshot +btrfs subvolume snapshot /btrfs-root /snapshot -cd /snapshot/source +cd "/snapshot/btrfs-root$BACKUP_RELATIVE_PATH" borg create --stats \ --list \ --filter=AMCE \ @@ -46,7 +46,7 @@ borg prune --list --stats \ borg compact --threshold=5 --cleanup-commits --verbose --progress -btrfs subvolume delete /snapshot/source +btrfs subvolume delete /snapshot/btrfs-root echo "Finished backup script at `date`" date > /health/backup_completion_time.log # this used by the healtcheck