Allow backing up non-root of volume
This commit is contained in:
parent
4c327ec98a
commit
c3280cbd78
2 changed files with 7 additions and 6 deletions
|
|
@ -26,9 +26,10 @@ services:
|
||||||
# Used for determining the health of the container
|
# Used for determining the health of the container
|
||||||
- MAX_BACKUP_AGE_SECONDS=86400 # default: 86400 (1d)
|
- MAX_BACKUP_AGE_SECONDS=86400 # default: 86400 (1d)
|
||||||
volumes:
|
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:/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
|
- /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
|
- 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
|
- health-flag:/health # this is used to determine if the backup was successful and when it was last run
|
||||||
|
|
|
||||||
|
|
@ -23,13 +23,13 @@ fi
|
||||||
# we want to stop the script immediately.
|
# we want to stop the script immediately.
|
||||||
set -e
|
set -e
|
||||||
|
|
||||||
if [ -d "/snapshot/source" ]; then
|
if [ -d "/snapshot/btrfs-root" ]; then
|
||||||
btrfs subvolume delete /snapshot/source
|
btrfs subvolume delete /snapshot/btrfs-root
|
||||||
fi
|
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 \
|
borg create --stats \
|
||||||
--list \
|
--list \
|
||||||
--filter=AMCE \
|
--filter=AMCE \
|
||||||
|
|
@ -46,7 +46,7 @@ borg prune --list --stats \
|
||||||
|
|
||||||
borg compact --threshold=5 --cleanup-commits --verbose --progress
|
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`"
|
echo "Finished backup script at `date`"
|
||||||
date > /health/backup_completion_time.log # this used by the healtcheck
|
date > /health/backup_completion_time.log # this used by the healtcheck
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue