Backup and Restore
A backup is one ZIP file with your content: documents, globals, translations, versions and media files. A restore writes it back with the same ids and dates, so relations, links and images keep working. This page shows how to make a backup, restore it, and move content to another database or environment.
The same file has three uses:
- Back up a site before an upgrade or on a schedule.
- Move content from production to your machine, or from SQLite to Postgres.
- Seed a new database with sample content. See Lifecycle hooks.
Two kinds of backup
| Kind | Holds | Made by | Restores into |
|---|---|---|---|
| Content archive | Documents, globals, translations, versions, media files | The admin, cms.export() | Any Tenon site with the same collections |
| Full backup | All of the above, plus users, their accounts and passkeys, API keys, invites and jobs | tenon backup, cms.export({ scope: "full" }) | The same kind of database, on the same tenoncms version |
Use a full backup to bring back a site as it was. Use a content archive to move content somewhere else.
Neither kind holds sessions, sign-in tokens, rate limits or image variants. Tables of your own app in the same database are never part of a backup.
Make a backup
Run this in your project:
npx tenon backup
It shows what the backup holds, suggests a file name like tenon-my-site-2026-11-12-1530.zip, and writes a full backup.
--content-onlywrites a content archive.--no-medialeaves the media files out.--dry-runshows what the backup would hold, and writes nothing.--url https://example.combacks up a deployed site. See tenon backup.
Admins open Manage → Backup and click Download ZIP under Export. Clear Include media files to leave them out.
The admin writes content archives only. For a full backup, use the CLI.
cms.export() returns the archive as a stream:
import { createWriteStream } from "node:fs";
import { Readable } from "node:stream";
import cms from "../tenon.config";
const archive = await cms.export();
Readable.fromWeb(archive).pipe(createWriteStream("backup.zip"));
{ media: false }leaves the media files out, for example when both sites use the same bucket.{ scope: "full" }writes a full backup.cms.exportSummary()takes the same options and returns what the archive would hold: rows per table, media files and bytes.
Restore a backup
npx tenon restore tenon-my-site-2026-11-12-1530.zip
The CLI checks the file first, and shows what it deletes and what it writes. It offers to back up the current data, then asks once more.
--dry-runstops after the check.--backupbacks up first without asking.--yesskips the questions. Without a terminal, it is required.
Admins open Manage → Backup, choose the file under Import and pick how to import it. The admin asks before it writes.
The admin imports content archives only. Users and API keys stay as they are.
import { openAsBlob } from "node:fs";
import cms from "../tenon.config";
await cms.import(await openAsBlob("backup.zip"), { mode: "replace" });
{ dryRun: true } checks the archive and writes nothing. It returns { errors, deletes, writes }: why the import would fail, what is stored now, and what the archive holds.
Choose how to import
A content archive can join the content that is already there. mode decides what happens to entries that exist in both:
| Mode | Admin label | What it does |
|---|---|---|
merge (default) | Add and overwrite | Adds new entries, and overwrites entries with the same id |
missing | Add only new entries | Adds entries whose id does not exist yet. Existing ones stay as they are |
replace | Replace all content | Deletes all documents, globals and versions first, then writes the file |
A full backup imports only with replace. The CLI always uses replace.
What an import does
- The import runs in one transaction. If it fails, the database stays as it was. Media files that were already copied stay in storage, and you can simply run the import again.
- It writes the stored rows as they are. No hooks, no validation and no webhooks run. To rebuild what your hooks keep up to date, use
afterImport. - Every collection and global of the archive MUST exist in your schema.
createdByandupdatedBykeep a user only when that user exists in the target. Otherwise they are empty.replacedrops the scheduled publishes of the old content, and leaves its media files in storage. Delete files you no longer need yourself.- Image variants are rendered again on request. With
prerender, the restore renders them for you.
Move content between environments
A content archive moves between any two Tenon sites with the same collections. The rows are the same on SQLite and Postgres, so this also moves a site to another database.
Copy production to your machine
- Sign in to the deployed site as an admin:
npx tenon login https://example.com - Back up the deployed site as a content archive:
npx tenon backup --url https://example.com --content-only - Restore it into your local project:
npx tenon restore tenon-example-2026-11-27-0930.zip
Your local users stay, because a content archive has none.
Move from SQLite to Postgres
- Back up the SQLite site with
npx tenon backup --content-only. - Point
databaseintenon.config.tsto Postgres. - Restore the file with
npx tenon restore.
The users do not move. Invite them again, or move them with your own script. A full backup MUST stay on the same kind of database.
Restore an older archive
An import does not migrate content to your current fields. It writes what the archive holds:
| In the archive | After the import |
|---|---|
| A collection that no longer exists | The import stops. Add the collection back, or remove it from the archive. |
| A field that you removed or renamed | The value stays in the database, but reads leave it out. The next save drops it. |
| A field whose type changed | Reads return the old value. The next save fails until an editor fixes it. |
| No value for a new required field | The field is empty. The next publish asks for it. |
A full backup also needs the same tenoncms version, so the same migrations. The check tells you what differs.
The same happens to content after a deploy that changes fields. See Upgrades and schema changes.
Large archives
Hosts limit the size of a request and a response. On Vercel, both are 4.5 MB. With S3 or R2 storage, the admin and the client avoid that limit:
- An export writes the archive into the bucket and downloads it through a link that works for 12 hours.
- An import uploads the file into the bucket in parts, then imports it from there and deletes it.
Without S3 or R2, import a large archive from a script with cms.import(), or with the CLI on your machine. An archive MUST stay under 4 GB.
Archives on their way in or out live in the bucket under .tenon/. The media library does not show them. An export stays there until the next export after 12 hours.
.tenon/ after one day.Who can back up
Admins can back up and restore. An API key needs the Backup permission: read to export, update to import. Use a key for backups from CI:
TENON_API_KEY=... npx tenon backup --url https://example.com
The HTTP routes are GET /_tenon/export and POST /_tenon/import. The client has client.export(), client.exportLink() and client.import().
The archive format
The ZIP holds one file per table, with one row per line:
| Entry | Holds |
|---|---|
manifest.json | Format version, date, default locale, localized fields, database kind, migrations, counts |
documents.ndjson | The documents, as stored |
document-locales.ndjson | The translations of each document |
globals.ndjson | The globals |
global-locales.ndjson | The translations of each global |
versions.ndjson | The version history |
media/<key> | The original of each media file |
tables/<table>.ndjson | In a full backup: users, accounts, API keys, jobs and the other tables |
Related resources
- tenon backup: every flag of
tenon backupandtenon restore. - Lifecycle hooks: seed a database from an archive, and run code after an import.
- Seed content: ship sample content with a starter.
- Media storage: S3 and R2 for large archives.