Upgrading
Move a containerised server to a newer image while keeping its data volume. The data stays where it is; only the container is replaced. Use the scripts for a container started by the single-container recipe, and the Compose steps below for any Compose recipe.
What you get
upgrade.sh/upgrade.ps1: pull the new image, check that it runs, stop the old container cleanly, and start a new one with the same name, ports and volume.- Compose steps that do the same for a Compose project.
Prerequisites
- A fresh copy of the volume, made with Backing up the volume or, with S3 backups, a
BACKUP DATABASEjust before. A newer server may change files in the data directory in ways an older one does not read, so going back means restoring that copy together with the old image. - The release notes of the version you are moving to: they list what changed and anything to do before or after.
What to edit
- Choose the new tag. Pin a full version (
1.1.0,1.1.0-alpine), notlatest: a pinned tag means every restart runs the version you chose, and an upgrade happens only when you change the tag. Stay on the same variant (Ubuntu, Alpine or RustFS) unless you mean to change it. Every variant runs as uid 10001, so a volume moves between them, but therustfsimage also has a second volume. - For the scripts, set
RASTERIZEDDB_PG_PASSWORDas forrun.sh, andNAME,VOLUMEandBIND(-Name,-Volume,-Bind) if you changed them when you started the container. Pass the same server flags you started it with.
Upgrade a single container
Linux and macOS:
export RASTERIZEDDB_PG_PASSWORD='the same password as before'
./upgrade.sh milendenev/rasterizeddb:1.1.0Windows:
$env:RASTERIZEDDB_PG_PASSWORD = 'the same password as before'
.\upgrade.ps1 milendenev/rasterizeddb:1.1.0Replace 1.1.0 with the version you are moving to. The tags of every release are on the image's Docker Hub and GitHub pages.
Upgrade a Compose project
-
Change the tag in
.env:textRASTERIZEDDB_IMAGE=milendenev/rasterizeddb:1.1.0 -
Pull it, then recreate the containers whose image changed. Compose stops the old container (within
stop_grace_period), starts the new one on the same volume, and leaves everything else alone:shdocker compose pull docker compose up -d
For the replication pair, upgrade one node at a time, so the other keeps serving:
docker compose pull
docker compose up -d --no-deps node2
# check node2 is back and its peer is up, then:
docker compose up -d --no-deps node1psql "host=127.0.0.1 port=5433 user=rasterized dbname=postgres sslmode=require" -c "SHOW REPLICATION"Check that it works
The version the new image runs:
docker run --rm milendenev/rasterizeddb:1.1.0 --versionThe container is up and reading the old data:
docker ps --filter name=rasterizeddb
docker logs rasterizeddb
psql "host=127.0.0.1 port=5432 user=rasterized dbname=postgres sslmode=require" -c "SELECT COUNT(*) FROM greetings"Use a table of your own in place of greetings.
Going back
If the new version misbehaves, stop it, restore the copy you took before the upgrade into a new volume, and start the old tag on that volume:
docker rm -f rasterizeddb
./restore.sh backups/rasterizeddb-data-20261127T101500Z.tar.gz rasterizeddb-before-upgrade
VOLUME=rasterizeddb-before-upgrade IMAGE=milendenev/rasterizeddb:1.0.1 ./run.shrestore.sh is in Backing up the volume, run.sh in single-container. Starting an older image on a volume a newer one has already opened is not supported, and an older server can refuse to open such a directory.
Clean up
Old images stay on the host until you remove them:
docker image ls milendenev/rasterizeddb
docker image rm milendenev/rasterizeddb:1.0.1 # the tag you moved away fromLimits
- The server is down from the moment the old container stops until the new one has opened the data, usually seconds. A replicated pair upgraded one node at a time keeps one node serving throughout.
RASTERIZEDDB_PG_PASSWORDdoes not change an existing server's password on an upgrade. UseALTER ROLE rasterized PASSWORD '…'.- 1.0.1 is the first release published as a Docker image.
The files
#!/usr/bin/env bash
# Moves a container started by the single-container recipe's run.sh to
# another image tag, keeping its data volume.
#
# export RASTERIZEDDB_PG_PASSWORD='the same password as before'
# ./upgrade.sh milendenev/rasterizeddb:1.1.0
# ./upgrade.sh milendenev/rasterizeddb:1.1.0 --log-level warn # server flags, as with run.sh
#
# NAME, VOLUME and BIND as for run.sh (defaults rasterizeddb,
# rasterizeddb-data, 127.0.0.1). Back the volume up first (backup-volume recipe).
set -euo pipefail
NEW_IMAGE="${1:?usage: ./upgrade.sh <image:tag> [server flags...]}"
shift
NAME="${NAME:-rasterizeddb}"
VOLUME="${VOLUME:-rasterizeddb-data}"
BIND="${BIND:-127.0.0.1}"
if [ -z "${RASTERIZEDDB_PG_PASSWORD:-}" ]; then
echo "Set RASTERIZEDDB_PG_PASSWORD (the container is recreated with it)." >&2
exit 1
fi
docker volume inspect "$VOLUME" >/dev/null
echo "Pulling $NEW_IMAGE..."
docker pull "$NEW_IMAGE"
echo "The new image runs: $(docker run --rm "$NEW_IMAGE" --version)"
if docker container inspect "$NAME" >/dev/null 2>&1; then
echo "Currently running: $(docker container inspect -f '{{.Config.Image}}' "$NAME")"
echo "Stopping $NAME (up to 60 s for a clean shutdown)..."
docker stop -t 60 "$NAME" >/dev/null
docker rm "$NAME" >/dev/null
fi
docker run -d \
--name "$NAME" \
--restart unless-stopped \
--stop-timeout 60 \
-e RASTERIZEDDB_PG_PASSWORD \
-p "$BIND:5432:5432" \
-p "$BIND:61170:61170" \
-v "$VOLUME:/var/lib/rasterizeddb" \
"$NEW_IMAGE" "$@" >/dev/null
echo "Started $NAME from $NEW_IMAGE on volume $VOLUME. Check it with: docker logs $NAME"# Moves a container started by the single-container recipe's run.ps1 to
# another image tag, keeping its data volume.
#
# $env:RASTERIZEDDB_PG_PASSWORD = 'the same password as before'
# .\upgrade.ps1 milendenev/rasterizeddb:1.1.0
# .\upgrade.ps1 milendenev/rasterizeddb:1.1.0 -ServerArgs '--log-level', 'warn' # server flags, as with run.ps1
#
# Back the volume up first (backup-volume recipe).
param(
[Parameter(Mandatory = $true, Position = 0)] [string] $NewImage,
[string] $Name = 'rasterizeddb',
[string] $Volume = 'rasterizeddb-data',
[string] $Bind = '127.0.0.1',
[Parameter(ValueFromRemainingArguments = $true)]
[string[]] $ServerArgs
)
$ErrorActionPreference = 'Stop'
if (-not $env:RASTERIZEDDB_PG_PASSWORD) {
throw 'Set $env:RASTERIZEDDB_PG_PASSWORD (the container is recreated with it).'
}
docker volume inspect $Volume | Out-Null
if ($LASTEXITCODE -ne 0) { throw "There is no volume named $Volume." }
Write-Host "Pulling $NewImage..."
docker pull $NewImage
if ($LASTEXITCODE -ne 0) { throw "docker pull $NewImage failed" }
$version = docker run --rm $NewImage --version
if ($LASTEXITCODE -ne 0) { throw "$NewImage does not run" }
Write-Host "The new image runs: $version"
$existing = docker ps -a -q --filter "name=^${Name}$"
if ($existing) {
Write-Host "Currently running: $(docker container inspect -f '{{.Config.Image}}' $Name)"
Write-Host "Stopping $Name (up to 60 s for a clean shutdown)..."
docker stop -t 60 $Name | Out-Null
if ($LASTEXITCODE -ne 0) { throw "docker stop $Name failed" }
docker rm $Name | Out-Null
if ($LASTEXITCODE -ne 0) { throw "docker rm $Name failed" }
}
$runArgs = @(
'run', '-d',
'--name', $Name,
'--restart', 'unless-stopped',
'--stop-timeout', '60',
'-e', 'RASTERIZEDDB_PG_PASSWORD',
'-p', "${Bind}:5432:5432",
'-p', "${Bind}:61170:61170",
'-v', "${Volume}:/var/lib/rasterizeddb",
$NewImage
)
if ($ServerArgs) { $runArgs += $ServerArgs }
docker @runArgs | Out-Null
if ($LASTEXITCODE -ne 0) { throw 'docker run failed' }
Write-Host "Started $Name from $NewImage on volume $Volume. Check it with: docker logs $Name"