Back up self-hosted AFFiNE before upgrades, storage moves, host migrations, and any operation that could affect persistent data. The most important recoverable data is Postgres, uploaded blobs, and modified configuration.
| Data | What it contains | Backup guidance |
|---|---|---|
| Postgres | AFFiNE application data. | Use the pg_dump flow below and keep the backup outside the container. |
| Blobs | Uploaded images, files, and other workspace blobs when using filesystem storage. | Back up the whole {UPLOAD_LOCATION} directory. |
| Configuration | Modified server configuration and operational settings. | Export modified configuration from the Admin Panel and keep a copy of your configuration files. |
Automatic database backup configuration from the Admin Panel is not available yet.
Postgres provides the official pg_dump command to dump your database into a custom-format backup file. See the PostgreSQL backup documentation for more details.
The following commands assume the default Docker Compose container name, database user, and database name. If you changed DB_USERNAME or DB_DATABASE in .env, replace the values accordingly.
After the command finishes, move affine.backup to durable storage outside the AFFiNE container directory.
Before restoring Postgres data, stop the AFFiNE instance so the application does not write to the database during restore.
Create and verify a backup of the current database before restoring another backup. Restoring the wrong file or restoring into the wrong environment can cause data loss.
The following commands assume the default Docker Compose container name and the DB_DATA_LOCATION, DB_USERNAME, and DB_DATABASE values shown below. If your .env uses different values, update the variables before running the commands.
After restore, open your AFFiNE instance and verify that users, workspaces, documents, and uploads are available as expected.
If blob storage is configured to use fs as the provider, back up the whole {UPLOAD_LOCATION} directory.
If you use an S3-compatible provider, follow your storage provider's backup and versioning practices.
Full automatic configuration backup is not implemented yet.
You can export all modified configurations from the Admin Panel. Keep that export together with a copy of your .env file and any files stored under {CONFIG_LOCATION} that are part of your deployment process.
Before relying on a self-hosted AFFiNE instance in production, verify that you can:
pg_dump.