Files
minecraft_server/scripts/mark_daily_backup.sh
Kappeh c49ac48205
All checks were successful
Deploy / Deploy (push) Successful in 2m18s
Add script to mark daily backup
2026-01-31 00:37:04 +00:00

24 lines
616 B
Bash

#!/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