Skip to content
Menu

Backup, Restore & Upgrades

Florabase guards against failed upgrades automatically, while keeping paired database + media backups as the authoritative recovery procedure.

  1. Read the release notes on GitHub Releases (and optionally verify release-manifest.json). Note that florabase-postgres may update within PostgreSQL 18 (Alpine/security updates), but never crosses a PostgreSQL major version automatically.
  2. Take a paired backup using your current release.
  3. Download compose.yaml from the target release tag (preserving your host bind paths, FLORABASE_DB_PASSWORD, and FLORABASE_CANONICAL_ORIGIN, or update your pinned image tags/digests), then pull and redeploy:
Terminal window
docker compose --project-name florabase pull
docker compose --project-name florabase up -d --wait
  • When the Alembic schema revision changes, backend automatically writes florabase-<from>-to-<to>-<UTC>.dump into $BACKUP/pre-upgrade/ and verifies it with pg_restore --list.
  • If the backup folder is missing, unwritable, or verification fails, nothing is migrated.
  • Migrations run inside one PostgreSQL transaction. If a migration fails, the database stays at the previous release and backend writes $DATA/state/upgrade-failed.env so restart loops never create duplicate dumps.
  • Image-only updates (same Alembic head) do not write a pre-upgrade dump — your step 2 paired backup is your rollback point.
  • Skipping releases directly is refused by the guard: to jump multiple releases, apply each intermediate release in order or restore a paired backup.

Run this block over SSH in bash (not sh/ash — on Synology NAS run bash first, as the script uses Bash arrays) from the directory holding your stack’s compose.yaml (adjust project and backup to a new, non-existing directory):

Terminal window
project=florabase
dc() { docker compose --project-name "$project" --file compose.yaml "$@"; }
backup='/absolute/path/to/a/new/backup-directory'
(
set -e
umask 077
mkdir "$backup"
dc stop frontend backend
dc exec -T db sh -ec '
export PGPASSWORD="$FLORABASE_DB_PASSWORD"
exec pg_dump -Fc --no-owner --no-privileges -U "$POSTGRES_USER" "$POSTGRES_DB"
' > "$backup/database.dump"
dc run --rm --no-deps -T backend python /app/scripts/attachment_artifacts.py verify
dc run --rm --no-deps -T backend python /app/scripts/attachment_artifacts.py archive \
> "$backup/media.tar"
files=(database.dump media.tar compose.yaml)
cp compose.yaml "$backup/"
if [ -f release-manifest.json ]; then
cp release-manifest.json "$backup/"
files+=(release-manifest.json)
fi
cd "$backup"
sha256sum "${files[@]}" > SHA256SUMS
)
dc up -d --wait

Store encrypted copies of the completed backup directory off the host, and keep database/owner credentials stored separately.

Always restore into a new, empty data folder prepared with the one-time folder setup under a distinct stack name — never overwrite a live installation in place.

Create a temporary restore-override.yaml next to the restore stack’s compose.yaml so container names do not collide with your live stack (and change the frontend port in the restore compose.yaml to e.g. 127.0.0.1:8081:8080 if restoring on the same host):

# restore-override.yaml (local only)
services:
db:
container_name: florabase-restore-db
backend:
container_name: florabase-restore-backend
frontend:
container_name: florabase-restore-frontend
  1. Start the fresh restore stack (pointing to the new empty data folder, backup folder, new DB password, and without FLORABASE_OWNER_* variables):
Terminal window
project=florabase-restore
dc() {
docker compose --project-name "$project" --file compose.yaml --file restore-override.yaml "$@"
}
dc up -d --wait
  1. Stop the app services and restore both database and media:
Terminal window
dc stop frontend backend
dc exec -T db sh -ec '
export PGPASSWORD="$FLORABASE_DB_PASSWORD"
psql -XAq -v ON_ERROR_STOP=1 -U "$POSTGRES_USER" -d "$POSTGRES_DB" \
-c "DROP SCHEMA public CASCADE" -c "CREATE SCHEMA public"
exec pg_restore --single-transaction --exit-on-error --no-owner --no-privileges \
-U "$POSTGRES_USER" -d "$POSTGRES_DB"
' < /path/to/backup/database.dump
dc run --rm --no-deps -T backend python /app/scripts/attachment_artifacts.py restore \
< /path/to/backup/media.tar
dc run --rm --no-deps -T backend python /app/scripts/attachment_artifacts.py verify
  1. Restart and verify:
Terminal window
dc up -d --wait

Sign in with the restored credentials, verify your records and original photos, then switch proxy traffic if migrating hosts.