scripts/backup-image.sh
Ref: Size: 1.5 KiB History
#!/usr/bin/env bash
# Build and push the nightly-backup image (see deploy/server/backup.Dockerfile).
#
# Unlike the server and site images this one is NOT built per release: it holds
# sqlite and nothing of eitri's, so it carries its own tag and is rebuilt only
# when the base image moves. BACKUP_IMAGE therefore includes the tag.
#
# Reads deploy.env (same file scripts/deploy.sh uses):
# BACKUP_IMAGE full ref to push, e.g. registry.example/eitri-backup:1
set -euo pipefail
cd "$(dirname "$0")/.."
ENV_FILE="${EITRI_DEPLOY_ENV:-$HOME/eitri-deploy/deploy.env}"
# shellcheck disable=SC1090
[ -f "$ENV_FILE" ] && . "$ENV_FILE"
: "${BACKUP_IMAGE:?backup-image: set BACKUP_IMAGE (with its tag) in $ENV_FILE}"
case "$BACKUP_IMAGE" in
*:*) ;;
*) echo "backup-image: BACKUP_IMAGE must include a tag, e.g. .../eitri-backup:1" >&2; exit 1 ;;
esac
# arm64: the control-plane node this job is pinned to (see plane.*.env NODE_NAME).
docker build --platform linux/arm64 -f deploy/server/backup.Dockerfile -t "$BACKUP_IMAGE" .
# Between build and push, like the other two: the gate is on what gets published.
./scripts/scan-image.sh "$BACKUP_IMAGE"
docker push "$BACKUP_IMAGE"
echo "backup-image: pushed $BACKUP_IMAGE — set BACKUP_IMAGE in the plane's ship.env and re-ship, or"
echo " kubectl -n <ns> patch cronjob eitri-server-backup --type=json \\"
echo " -p='[{\"op\":\"replace\",\"path\":\"/spec/jobTemplate/spec/template/spec/containers/0/image\",\"value\":\"$BACKUP_IMAGE\"}]'"