From fa275b8b740a5e563f161e0d815952f57667723a Mon Sep 17 00:00:00 2001 From: Andras Schmelczer Date: Sun, 2 Jun 2024 12:41:32 +0100 Subject: [PATCH] Small improvements --- docker-compose.yml | 11 ++++++----- src/backup-wrapper.sh | 3 ++- src/backup.sh | 11 +++++++++-- 3 files changed, 17 insertions(+), 8 deletions(-) diff --git a/docker-compose.yml b/docker-compose.yml index 4acc7ab..88a553f 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -18,10 +18,11 @@ services: - BORG_PASSPHRASE_1=$PASSWORD - BORG_REPO_1=/local-backup - - KEEP_DAILY=6 # the following are passed to `borg prune` - - KEEP_WEEKLY=3 - - KEEP_MONTHLY=48 - - KEEP_YEARLY=10 + # the following are passed to `borg prune` + - KEEP_DAILY=6 # default: 6 + - KEEP_WEEKLY=3 # default: 3 + - KEEP_MONTHLY=48 # default: 48 + - KEEP_YEARLY=10 # default: 0 volumes: - /volumes:/source:ro # we will backup this folder, we mustn't change it, so it's readonly - /volumes/backup:/snapshot # we must mount a btrfs path for the snapshot to be put at, this is just a temporary path @@ -29,7 +30,7 @@ services: - borg-cache:/root/.cache/borg # speed up subsequent backups - /bulk/backup:/local-backup # this is an example target backup path for BORG_REPO_1 from above - - /volumes/backup/id_rsa:/root/.ssh/id_rsa # this is an example for mounting an ssh key for a remote repo (BORG_REPO_0 above) + - /volumes/backup/config/id_rsa:/root/.ssh/id_rsa # this is an example for mounting an ssh key for a remote repo (BORG_REPO_0 above) cap_add: - SYS_ADMIN # we need this capability to snapshot a btrfs volume diff --git a/src/backup-wrapper.sh b/src/backup-wrapper.sh index 47751ea..2e55ecb 100755 --- a/src/backup-wrapper.sh +++ b/src/backup-wrapper.sh @@ -37,7 +37,8 @@ configure_environment() { } main() { - if [ -n "$BORG_PASSPHRASE" ] && [ -n "$BORG_REPO" ]; then + if [ -n "$BORG_REPO" ]; then + # fallback case if multi-target backup isn't needed execute_script else local index=0 diff --git a/src/backup.sh b/src/backup.sh index ddeb430..6039dae 100755 --- a/src/backup.sh +++ b/src/backup.sh @@ -18,7 +18,9 @@ if [ $? -ne 0 ]; then borg init --encryption=repokey fi -# the above command will fail if the repo hasn't been already initialized, so we can ignore the return status +# The above command will fail if the repo hasn't been already initialized, +# so we can ignore the return status. However, if any of the commands below fail, +# we want to stop the script immediately. set -e if [ -d "/snapshot/source" ]; then @@ -28,7 +30,12 @@ fi btrfs subvolume snapshot /source /snapshot cd /snapshot/source -borg create --stats --list --filter=AMCE --files-cache=ctime,size --compression=zstd,12 --exclude-from /exclude.conf ::"{hostname}-{now:%Y-%m-%dT%H:%M:%S}" . +borg create --stats \ + --list \ + --filter=AMCE \ + --files-cache=ctime,size,inode \ + --compression=zstd,12 \ + --exclude-from /exclude.conf ::"{hostname}-{now:%Y-%m-%dT%H:%M:%S}" . cd - borg prune --list --stats \