Merge pull request #2428 from nextcloud/enh/noid/borg-retention-policy

allow to adjust borgs retention policy
This commit is contained in:
Simon L 2023-05-30 11:28:36 +02:00 committed by GitHub
commit ef43d19a27
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
9 changed files with 24 additions and 8 deletions

View file

@ -18,3 +18,4 @@ COPY --chmod=770 *.sh /
ENTRYPOINT ["/start.sh"]
LABEL com.centurylinklabs.watchtower.monitor-only="true"
ENV BORG_RETENTION_POLICY="--keep-within=7d --keep-weekly=4 --keep-monthly=6"

View file

@ -167,11 +167,13 @@ if [ "$BORG_MODE" = backup ]; then
rm -f "/nextcloud_aio_volumes/nextcloud_aio_nextcloud_data/skip.update"
# Prune options
BORG_PRUNE_OPTS=(--stats --keep-within=7d --keep-weekly=4 --keep-monthly=6 "$BORG_BACKUP_DIRECTORY")
set -x
read -ra BORG_PRUNE_OPTS <<< "$BORG_RETENTION_POLICY"
set +x
# Prune archives
echo "Pruning the archives..."
if ! borg prune --glob-archives '*_*-nextcloud-aio' "${BORG_PRUNE_OPTS[@]}"; then
if ! borg prune --stats --glob-archives '*_*-nextcloud-aio' "${BORG_PRUNE_OPTS[@]}" "$BORG_BACKUP_DIRECTORY"; then
echo "Failed to prune archives!"
exit 1
fi
@ -202,7 +204,7 @@ if [ "$BORG_MODE" = backup ]; then
exit 1
fi
echo "Pruning additional volumes..."
if ! borg prune --glob-archives '*_*-additional-docker-volumes' "${BORG_PRUNE_OPTS[@]}"; then
if ! borg prune --stats --glob-archives '*_*-additional-docker-volumes' "${BORG_PRUNE_OPTS[@]}" "$BORG_BACKUP_DIRECTORY"; then
echo "Failed to prune additional docker-volumes archives!"
exit 1
fi
@ -232,7 +234,7 @@ if [ "$BORG_MODE" = backup ]; then
exit 1
fi
echo "Pruning additional host mounts..."
if ! borg prune --glob-archives '*_*-additional-host-mounts' "${BORG_PRUNE_OPTS[@]}"; then
if ! borg prune --stats --glob-archives '*_*-additional-host-mounts' "${BORG_PRUNE_OPTS[@]}" "$BORG_BACKUP_DIRECTORY"; then
echo "Failed to prune additional host-mount archives!"
exit 1
fi