From c49ac48205c0d3592197a597c1f4574316a5ad9f Mon Sep 17 00:00:00 2001 From: Kappeh Date: Sat, 31 Jan 2026 00:37:04 +0000 Subject: [PATCH] Add script to mark daily backup --- scripts/mark_daily_backup.sh | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) create mode 100644 scripts/mark_daily_backup.sh diff --git a/scripts/mark_daily_backup.sh b/scripts/mark_daily_backup.sh new file mode 100644 index 0000000..e43c488 --- /dev/null +++ b/scripts/mark_daily_backup.sh @@ -0,0 +1,23 @@ +#!/usr/bin/env bash + +if [ "$EUID" -ne 0 ]; then + echo "This script must be run by the root user" >&2 + exit 1 +fi + +if docker compose run --rm init sh -c '[ ! -L /backups/latest ]'; then + # There is no latest backup, nothing to do + exit 0 +fi + +if docker compose run --rm init sh -c '[ -e /backups/daily ]'; then + # Daily marker exists, update it + docker compose run --rm init sh -c ' + rm /backups/daily && + cp -P /backups/latest /backups/daily + ' || exit 1 +else + # Daily marker does not exist, create it + docker compose run --rm init cp -P /backups/latest /backups/daily || exit 1 +fi +