diff options
author | Julien Dessaux | 2024-08-29 20:22:56 +0200 |
---|---|---|
committer | Julien Dessaux | 2024-08-29 20:22:56 +0200 |
commit | 48f2e9a2cbc35aefc11e14e8504f0090414291c8 (patch) | |
tree | 9ec3b7fe4b64a04eddbcf7177133ddcd292ab8b5 /stdlib/backups/borg/borg-script-template | |
parent | feat(services): support service timers for which a running state means waiting (diff) | |
download | gonf-48f2e9a2cbc35aefc11e14e8504f0090414291c8.tar.gz gonf-48f2e9a2cbc35aefc11e14e8504f0090414291c8.tar.bz2 gonf-48f2e9a2cbc35aefc11e14e8504f0090414291c8.zip |
feat(stdlib): added a basic borg client custom promise
Diffstat (limited to '')
-rw-r--r-- | stdlib/backups/borg/borg-script-template | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/stdlib/backups/borg/borg-script-template b/stdlib/backups/borg/borg-script-template new file mode 100644 index 0000000..c09c297 --- /dev/null +++ b/stdlib/backups/borg/borg-script-template @@ -0,0 +1,27 @@ +#!/usr/bin/env bash +set -euo pipefail + +on_exit() { + exit $? +} +trap on_exit EXIT + +archiveName="%s-%s-$(date +%%Y-%%m-%%dT%%H:%%M:%%S)" +archiveSuffix=".failed" + +# Run borg init if the repo doesn't exist yet +if ! borg list > /dev/null; then + borg init --encryption none +fi +( + borg create \ + --compression auto,zstd \ + "::${archiveName}${archiveSuffix}" \ + '%s' +) +borg rename "::${archiveName}${archiveSuffix}" "${archiveName}" + +borg prune \ + --keep-daily=14 --keep-monthly=3 --keep-weekly=4 \ + --glob-archives '%s-%s*' +borg compact |