Small improvements
This commit is contained in:
parent
b9b0cae0d2
commit
fa275b8b74
3 changed files with 17 additions and 8 deletions
|
|
@ -18,10 +18,11 @@ services:
|
||||||
- BORG_PASSPHRASE_1=$PASSWORD
|
- BORG_PASSPHRASE_1=$PASSWORD
|
||||||
- BORG_REPO_1=/local-backup
|
- BORG_REPO_1=/local-backup
|
||||||
|
|
||||||
- KEEP_DAILY=6 # the following are passed to `borg prune`
|
# the following are passed to `borg prune`
|
||||||
- KEEP_WEEKLY=3
|
- KEEP_DAILY=6 # default: 6
|
||||||
- KEEP_MONTHLY=48
|
- KEEP_WEEKLY=3 # default: 3
|
||||||
- KEEP_YEARLY=10
|
- KEEP_MONTHLY=48 # default: 48
|
||||||
|
- KEEP_YEARLY=10 # default: 0
|
||||||
volumes:
|
volumes:
|
||||||
- /volumes:/source:ro # we will backup this folder, we mustn't change it, so it's readonly
|
- /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
|
- /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
|
- 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
|
- /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:
|
cap_add:
|
||||||
- SYS_ADMIN # we need this capability to snapshot a btrfs volume
|
- SYS_ADMIN # we need this capability to snapshot a btrfs volume
|
||||||
|
|
|
||||||
|
|
@ -37,7 +37,8 @@ configure_environment() {
|
||||||
}
|
}
|
||||||
|
|
||||||
main() {
|
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
|
execute_script
|
||||||
else
|
else
|
||||||
local index=0
|
local index=0
|
||||||
|
|
|
||||||
|
|
@ -18,7 +18,9 @@ if [ $? -ne 0 ]; then
|
||||||
borg init --encryption=repokey
|
borg init --encryption=repokey
|
||||||
fi
|
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
|
set -e
|
||||||
|
|
||||||
if [ -d "/snapshot/source" ]; then
|
if [ -d "/snapshot/source" ]; then
|
||||||
|
|
@ -28,7 +30,12 @@ fi
|
||||||
btrfs subvolume snapshot /source /snapshot
|
btrfs subvolume snapshot /source /snapshot
|
||||||
|
|
||||||
cd /snapshot/source
|
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 -
|
cd -
|
||||||
|
|
||||||
borg prune --list --stats \
|
borg prune --list --stats \
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue