Skip to content

Update and migrate: Image rollback

Return to the exact previous image and restore matching data whenever a schema or migration ran.

Use the recorded previous digest with its matching PostgreSQL dump and /data archive. A channel switch is allowed only after release-note review and a matched backup.

  • DiscVault v26 stable · ghcr.io/helmerznl/discvault:latest
  • restore the matching data before starting the previous image
  • PostgreSQL + /data
  • DiscVault v26 beta · ghcr.io/helmerznl/discvault:beta
  • restore the matching data before starting the previous image
  • PostgreSQL + /data
  • matching backup set
  • recorded immutable PREVIOUS_IMAGE
  1. Stop: next-api + next-worker + next-mcp
  2. Restore: matching /data archive
  3. Restore: matching PostgreSQL dump · pg_restore --exit-on-error
  4. Start: PREVIOUS_IMAGE → API health → worker + MCP
Terminal window
set -euo pipefail
BACKUP_ID=20260714T180000Z
cd /opt/discvault
. "/srv/backups/discvault-$BACKUP_ID.env"
test -n "$PREVIOUS_IMAGE"
export DISCVAULT_IMAGE="$PREVIOUS_IMAGE"
docker pull "$DISCVAULT_IMAGE"
ENV_FILE=/opt/discvault/.env
ENV_TMP="$(mktemp "$ENV_FILE.restore.XXXXXX")"
trap 'rm -f "$ENV_TMP"' EXIT
awk -v image="$DISCVAULT_IMAGE" '
/^DISCVAULT_IMAGE=/ { print "DISCVAULT_IMAGE=" image; found=1; next }
{ print }
END { if (!found) exit 42 }
' "$ENV_FILE" > "$ENV_TMP"
chmod 0600 "$ENV_TMP"
docker compose --env-file .env -p discvault -f compose.yaml stop next-worker next-mcp next-api
mv /srv/discvault "/srv/discvault.failed-$(date -u +%Y%m%dT%H%M%SZ)"
tar --acls --xattrs -C /srv -xzf \
"/srv/backups/discvault-data-$BACKUP_ID.tgz"
docker compose --env-file .env -p discvault -f compose.yaml up -d postgres
docker compose --env-file .env -p discvault -f compose.yaml exec -T postgres \
sh -c 'dropdb --if-exists --force -U "$POSTGRES_USER" "$POSTGRES_DB"'
docker compose --env-file .env -p discvault -f compose.yaml exec -T postgres \
sh -c 'createdb -U "$POSTGRES_USER" "$POSTGRES_DB"'
docker compose --env-file .env -p discvault -f compose.yaml exec -T postgres \
sh -c 'pg_restore --exit-on-error --no-owner -U "$POSTGRES_USER" -d "$POSTGRES_DB"' \
< "/srv/backups/discvault-$BACKUP_ID.dump"
docker compose --env-file .env -p discvault -f compose.yaml up -d --force-recreate next-api
curl --fail http://localhost:6080/api/next/health
docker compose --env-file .env -p discvault -f compose.yaml \
up -d --force-recreate next-worker next-mcp
docker compose --env-file .env -p discvault -f compose.yaml ps
mv "$ENV_TMP" "$ENV_FILE"
trap - EXIT

The recorded previous image is running and the restored library passes health and data checks.

  • PREVIOUS_IMAGE · @sha256:
  • restore the matching data before starting the previous image
  • library counts and sampled media match the selected backup

Update and migrate: DiscVault 26 migration