Database Backup & Restore

Export and restore selected Payload CMS MongoDB collections as portable JSON from the admin panel.

Community 0 45/wk MIT v0.1.0

Installation

pnpm add @yairl/payload-db-backup-restore

About

This plugin adds a backup and restore screen to a Payload 3 admin panel. Pick the collections you want from a checklist, hit download, and you get a single JSON file with every document in those collections. Restore reads that file back and reinserts the rows. The whole thing mounts at `/admin/backup` and adds a sidebar shortcut by default. The file is written with EJSON, so MongoDB types like `ObjectId`, `Date`, and `Decimal128` round-trip byte for byte rather than degrading into plain strings. When a collection has drafts enabled, its `_<slug>_versions` sidecar is exported and restored alongside the main slug automatically. Restore uses raw Mongoose `insertMany`, not `payload.create`. That is deliberate: Payload hooks such as `beforeChange` and `afterChange` do not fire, so a bulk restore will not re-run title setters or trigger thousands of revalidation calls. The `_id` of each document is preserved exactly as it was in the backup. There is a "drop before restore" option, on by default, that empties the target collection first; turn it off and `insertMany` runs with `ordered: false`, so duplicate `_id` rows error individually while the rest succeed. It is MongoDB only. The code reaches into `req.payload.db.collections` and `db.versions`, and the Postgres and SQLite adapters do not expose the same shape. It also does not cover uploaded blob files on disk, global admin settings, or Payload's internal system collections. Access defaults to a `req.user.roles.includes('admin')` check, which you will likely want to override to `req => !!req.user` unless you have added a `roles` field to your Users collection. Three REST endpoints sit behind that same check if you want to script backups from outside the admin UI.

Package info

Package name
@yairl/payload-db-backup-restore
Latest version
0.1.0
Unpacked size
51 kB
License
MIT
Weekly downloads
45
Last publish
Jul 4, 2026

Similar plugins

More in Admin