Skip to content

Backups: what Kywi does not do for you

Backing up a Kywi deployment is a pg_dump plus the uploads volume, run by you: the CLI ships six commands and none of them is a backup.

The CLI ships six commands — migrate, migrate:generate, migrate:status, seed, seed:demo, upgrade:variant-containers — and there is no backup or export route in the API either. Two things in the tree are named backup and neither is one: upgrade:variant-containers --backup writes the layout JSON of the documents that single command is about to rewrite, and create-kywi-app upgrade's .kywi-upgrade/<timestamp>/ holds source files it refused to overwrite. Both are undo for one operation.

The practice: dump before every schema-bearing change

Take the dump through a public TCP proxy, since an operator machine cannot reach a platform's internal database host, and name the file for what it precedes — <db>-pre-0.21.0.sql. Every upgrade in this deployment's record starts with one, which is what makes Upgrading between minor versions a reversible operation at all: nothing in Kywi rolls back an applied migration.

dump, and restore into an empty databasebash
PROXY="postgresql://$PGUSER:$PGPASSWORD@$PROXY_HOST:$PROXY_PORT/$PGDATABASE?sslmode=require"
TARGET="postgresql://$TGT_USER:$TGT_PASSWORD@$TGT_PROXY_HOST:$TGT_PROXY_PORT/$TGT_DATABASE?sslmode=require"

pg_dump --no-owner --no-privileges "$PROXY" > kywi-pre-0.24.0.sql

psql "$TARGET" -v ON_ERROR_STOP=1 -f kywi-pre-0.24.0.sql

$TARGET must point at an empty database, never back at $PROXY — restoring a dump into the database it was just taken from replays every row on top of live production instead of proving the backup. --no-owner --no-privileges is what makes the dump loadable by a different role than it was taken as, which is the normal case on managed Postgres; -v ON_ERROR_STOP=1 is what turns a half-applied restore into a failed one. Verify a restore by counting, not by opening the site: tables, content rows, users, audiences and experiments. A restore that lost the audience rows renders a perfectly normal-looking site to everyone.

A dump is not the whole deployment

Media uploaded through the local storage provider is on a mounted volume, not in the database, so no pg_dump contains it — and a second service on the same database with no volume of its own does not even see it. Back the volume up separately, or move media to object storage, where the storage provider's own durability applies. Configuration is the other half: kywi.config.ts owns each site's name, domain, locale and theme, and reconciliation rewrites the database row from it, so the repository is the backup for those four columns and restoring an older dump does not revive them.

What the database will not keep for you

Version history is capped, by deletion, at the fifty most recent versions per content item. Every direct save, publish and approval snapshots a version and then deletes everything beyond the newest fifty for that item — the cap is a constant with no config field and no schema column behind it. So an editor or an agent iterating on one page can push a state out of the table within a session, and once it is deleted the database no longer contains it in any form. Rollback covers the recent past (Version history and rollback); a dump is the only place an older state survives. That is the strongest argument for taking one on a schedule and not only before an upgrade.