24 lines
616 B
Bash
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
|
|
|