Operations

Backup and Restore

Save all content in one file and write it back.

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

KindHoldsMade byRestores into
Content archiveDocuments, globals, translations, versions, media filesThe admin, cms.export()Any Tenon site with the same collections
Full backupAll of the above, plus users, their accounts and passkeys, API keys, invites and jobstenon 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-only writes a content archive. --no-media leaves the media files out.
  • --dry-run shows what the backup would hold, and writes nothing.
  • --url https://example.com backs up a deployed site. See tenon backup.

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-run stops after the check.
  • --backup backs up first without asking.
  • --yes skips the questions. Without a terminal, it is required.
A restore of a full backup replaces all data: content, users and API keys. Everyone is signed out. It cannot be undone, so back up the current data first.

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:

ModeAdmin labelWhat it does
merge (default)Add and overwriteAdds new entries, and overwrites entries with the same id
missingAdd only new entriesAdds entries whose id does not exist yet. Existing ones stay as they are
replaceReplace all contentDeletes 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.
  • createdBy and updatedBy keep a user only when that user exists in the target. Otherwise they are empty.
  • replace drops 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

  1. Sign in to the deployed site as an admin:
    npx tenon login https://example.com
    
  2. Back up the deployed site as a content archive:
    npx tenon backup --url https://example.com --content-only
    
  3. 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

  1. Back up the SQLite site with npx tenon backup --content-only.
  2. Point database in tenon.config.ts to Postgres.
  3. 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 archiveAfter the import
A collection that no longer existsThe import stops. Add the collection back, or remove it from the archive.
A field that you removed or renamedThe value stays in the database, but reads leave it out. The next save drops it.
A field whose type changedReads return the old value. The next save fails until an editor fixes it.
No value for a new required fieldThe 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.

With a public bucket, anyone who knows the random name of an archive can download it until it is deleted. Add a lifecycle rule to the bucket that deletes objects under .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:

EntryHolds
manifest.jsonFormat version, date, default locale, localized fields, database kind, migrations, counts
documents.ndjsonThe documents, as stored
document-locales.ndjsonThe translations of each document
globals.ndjsonThe globals
global-locales.ndjsonThe translations of each global
versions.ndjsonThe version history
media/<key>The original of each media file
tables/<table>.ndjsonIn a full backup: users, accounts, API keys, jobs and the other tables