Back up and restore
Create an encrypted archive in maintenance mode and verify recovery on an isolated installation.
Create an archive
- Set
MAINTENANCE_MODE=1on the API and jobs runtimes and apply the configuration. Pause writes and delivery and drain in-flight requests. Keep the operator portal reachable. - Configure
BACKUP_KEYwith 32 random bytes encoded in Base64. Store the key separately from the archive. - In Settings → Backups, create and download the
.backupfile. It includes application data, referenced original Markdown, managed images and the erasure records at snapshot time. - Keep an independently protected, current copy of the object store’s
erased/directory. A restore of an older archive needs newer records to honor deletions made since the snapshot.
Restore to an empty target
Apply schema migrations to an isolated new instance and provision the recovery owner with the same ADMIN_USER_ID. Configure the source backup key and keep maintenance mode on. Retain the original BETTER_AUTH_SECRET for encrypted OAuth tokens. Copy the current erased/ ledger first, then use Import backup to upload the archive.
An occupied target, invalid key or modified payload is rejected. After an interruption, resume with the same archive on the same target. Sign in again and check sites, comment counts, images and moderation state. Confirm erased content is still inaccessible before reopening traffic and delivery.
Larger installations
Interactive imports have a 32 MiB limit. For larger installations, capture the database and objects under the same write freeze. Use pg_dump for PostgreSQL, the SQLite backup API or .backup for SQLite, or export both D1 databases and copy R2 objects on Cloudflare. Validate the result through an isolated restore drill.