Add script to mark daily backup
All checks were successful
Deploy / Deploy (push) Successful in 2m18s
All checks were successful
Deploy / Deploy (push) Successful in 2m18s
This commit is contained in:
23
scripts/mark_daily_backup.sh
Normal file
23
scripts/mark_daily_backup.sh
Normal file
@@ -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
|
||||||
|
|
||||||
Reference in New Issue
Block a user