# Backups - `pg_dump -Fc` runs **inside** the database container (client always matches the server) and streams straight to the target: local disk (`/data/backups`) or any S3-compatible bucket. Memory stays constant and nothing touches a temp file. - A PostgreSQL backup holds **one database** of the instance: the service's own (`POSTGRES_DB`; `postgres` for services created since 0.17) unless you pick another one your app created. *Back up now* and each schedule list the instance's databases to choose from, so you never type a name. The backup history shows which database each backup holds, and a restore puts back that same database, creating it if the instance no longer has it. - A backup only counts once `pg_dump` exits 0; partial uploads are deleted. Each backup records size, SHA-256, server version, the service's image and duration, and a PostgreSQL one the extensions the database uses (`postgis`, `vector`…). A restore into a server whose image lacks one of them is refused before anything changes: restore a PostGIS backup into a PostGIS database. - Restores load the dump into a scratch database and swap it in by rename, so the result is exactly the backup and a failed restore leaves live data untouched. Apps referencing the database are stopped meanwhile. The checksum is verified. - **MySQL and MariaDB** are dumped by `mysqldump` (`mariadb-dump`) in one consistent snapshot (`--single-transaction`), with routines, triggers and events, gzipped by the manager; **MongoDB** by `mongodump --archive --gzip`, every database of the instance. Same as `pg_dump`: inside the container, a backup only counts once the tool exits 0. A dump restores into a service of the same kind. The backup is first read through (checksum, decryption, gzip), so a damaged one changes nothing. A MySQL dump is then loaded into a scratch database, and only once that worked into the emptied live database. A MongoDB restore replaces each collection the backup holds (`mongorestore --drop`; `admin`, `config` and `local` are left alone), and collections created since stay. - **Volumes** of Redis services and of apps are backed up as a gzipped tar (one folder per volume, owners and permissions kept), read by a short-lived network-less `busybox` container that mounts them read-only; the service keeps running, so set a *pre-backup command* on an app to flush its files first. Restores extract into a staging volume and check the checksum before touching anything, then stop the service, replace each volume's content and start it again. - Backups outlive their service and project; delete them explicitly. - Next to each backup, a small `.json` holds what the history shows about it (project, service, kind, database, size, checksum, version, image), encrypted like the backup. Another manager given the same storage reads it to adopt the backup (see [Moving to another manager](#moving-to-another-manager)). - **Schedules** (cron, UTC unless `CRON_TZ=` is given) back up a service to a target and then apply retention to *their own* backups: keep the last N, plus the newest of each of the last N days / ISO weeks / months. Manual backups are never pruned. A run that finds the service busy (deploy, restore) retries for 15 minutes. ## Restore tests A backup nobody restored is a hope. *Verify* (or a schedule with restore tests on, the default) restores a backup into an empty database of a throwaway PostgreSQL container with no network: the service's image when it still runs the backup's major version, else the image that made the backup (PostGIS…), else the official one of that major. It then runs `ANALYZE` and records tables, estimated rows, database size and duration on the backup. A MySQL, MariaDB or MongoDB dump goes into a throwaway server of the service's image (once the service is gone, the one that made the backup, or the kind's default for backups that don't record it) and records tables (collections), exact rows (documents) and size. The container and its volume are always removed; one test runs at a time. A volume backup's test reads the whole archive back (decrypt, gunzip, list) in a throwaway container, checks the checksum and records the number of entries. ## Encryption An S3 target can encrypt everything stored on it with [age](https://age-encryption.org) (chosen at creation, or later with the lock icon; the key never changes). Copy the key (*Show key*) somewhere safe: without it, those backups are unreadable if this server is lost. A storage another manager encrypted (a project moved here, a rebuilt server) takes that manager's key: paste it in *Use an existing key* when adding or encrypting the storage. It is checked against an encrypted backup already there, and refused if it can't open it. Offline: ```sh age -d -i key.txt shop-20260930T030000Z-xxxx.dump.age | pg_restore -d "$DATABASE_URL" --no-owner age -d -i key.txt web-20260930T030000Z-xxxx.tar.gz.age | tar -xzf - --numeric-owner # volumes age -d -i key.txt sql-20260930T030000Z-xxxx.sql.gz.age | gunzip | mysql -h 127.0.0.1 -u root -p app age -d -i key.txt docs-20260930T030000Z-xxxx.archive.gz.age | mongorestore --archive --gzip --uri "$MONGO_URL" ``` ## Moving to another manager A manager only lists the backups it made. To take a project's history along (a project moved with *Export with secrets* → *Import*, a rebuilt server), give the new manager the same storage: same bucket and prefix, and if it is encrypted, the old manager's key in *Use an existing key*. Then Settings › Storage › *Find backups from another manager* (folder icon; MCP `scan_storage`) reads the record next to each backup and adds the ones this manager doesn't know to Backups: - A backup goes to the service with the same project and service name, if it can restore into it (a PostgreSQL dump into PostgreSQL, a MySQL dump into MySQL…). The others are listed without a service: open one and *Restore into…* a service you pick. - They keep their date, size, checksum and versions, but belong to no schedule: retention never deletes them. Delete them by hand. - Only backups with a record are found: those made since 0.40. Older ones and manager snapshots are left alone; restore them [by hand](#encryption). - Both managers then see the same files: one deleting a backup (by hand or by its retention) deletes it for the other too, which then fails to restore it. Scanning again only adds what's new. ## Manager state The manager's own SQLite file (projects, services, schedules, credentials, keys) is snapshotted with `VACUUM INTO` on schedules you manage in Backups › Manager state, to any storage, with the same retention rules as databases. On first start a daily schedule to local disk keeping the last 14 is created (`KIPITINY_MANAGER_BACKUP_CRON` / `_TARGET` / `_KEEP`, `off` to skip it). These snapshots contain every secret the manager holds: prefer an encrypted storage. To restore one, stop the manager and replace `/data/kipitiny.db` with the file (delete `kipitiny.db-wal` and `kipitiny.db-shm` first). ## Targets S3-compatible targets take a bucket, an optional prefix and credentials. Cloudflare R2, AWS S3, Backblaze B2 and Hetzner Object Storage have their own form, which builds the endpoint from the account ID and jurisdiction (R2: default, EU or FedRAMP, as chosen when the bucket was created), the region (AWS, B2) or the location (Hetzner). Any other provider (MinIO, Garage, Scaleway, OVH…) takes the endpoint, region and HTTPS setting directly. Targets are checked (a test object is written and deleted) before they are saved.