---
title: "Back up and restore"
description: "Create an encrypted archive in maintenance mode and verify recovery on an isolated installation."
---

> Documentation Index
> Fetch the complete documentation index at: https://blua.pwp.sh/llms.txt
> Use this file to discover all available pages before exploring further.

# Back up and restore

## Create an archive

1. Set `MAINTENANCE_MODE=1` on the API and jobs runtimes and apply the configuration. Pause writes and delivery and drain in-flight requests. Keep the operator portal reachable.
2. Configure `BACKUP_KEY` with 32 random bytes encoded in Base64. Store the key separately from the archive.
3. In **Settings → Backups**, create and download the `.backup` file. It includes application data, referenced original Markdown, managed images and the erasure records at snapshot time.
4. 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.

Source: https://blua.pwp.sh/docs/en/operations/backups/
