Backup and restore plugin for Payload 3 projects running on the Postgres or Vercel Postgres adapter. It adds an admin dashboard, REST endpoints and cron routes, and writes archives to Vercel Blob or S3-compatible storage such as AWS S3, Cloudflare R2 and MinIO. Backups are taken in a single consistent transaction and restored atomically by default. Requires Next.js and React 19; production setups need a migration for the plugin's collections.
Payload CMS plugin for PostgreSQL backup and recovery via Vercel Blob or AWS S3 (S3-compatible: R2, MinIO)
Installation
npm i payload-plugin-backup-postgres3
Stars
0
Forks
0
Open Issues
Today
Last Updated
118
Weekly Downloads
v0.5.0
npm Version
1.1 MB
Unpacked Size
3
Dependencies
3+3 since Nov 8
| Date | Stars |
|---|---|
| Dec 6, 2026 | 3 |
| Dec 5, 2026 | 3 |
| Dec 4, 2026 | 3 |
| Dec 3, 2026 | 3 |
| Dec 2, 2026 | 3 |
| Dec 1, 2026 | 2 |
| Nov 30, 2026 | 2 |
| Nov 29, 2026 | 1 |
| Nov 28, 2026 | 1 |
| Nov 27, 2026 | 1 |
| Nov 26, 2026 | 0 |
| Nov 25, 2026 | 0 |
| Nov 24, 2026 | 0 |
| Nov 23, 2026 | 0 |
| Nov 22, 2026 | 0 |
| Nov 21, 2026 | 0 |
| Nov 20, 2026 | 0 |
| Nov 19, 2026 | 0 |
| Nov 18, 2026 | 0 |
| Nov 17, 2026 | 0 |
| Nov 16, 2026 | 0 |
| Nov 15, 2026 | 0 |
| Nov 14, 2026 | 0 |
| Nov 13, 2026 | 0 |
| Nov 12, 2026 | 0 |
| Nov 11, 2026 | 0 |
| Nov 10, 2026 | 0 |
| Nov 9, 2026 | 0 |
| Nov 8, 2026 | 0 |
123+123 since Nov 12
| Date | Weekly downloads |
|---|---|
| Dec 6, 2026 | 123 |
| Dec 5, 2026 | 182 |
| Dec 4, 2026 | 241 |
| Dec 3, 2026 | 508 |
| Dec 2, 2026 | 1,408 |
| Dec 1, 2026 | 1,711 |
| Nov 30, 2026 | 1,692 |
| Nov 29, 2026 | 1,676 |
| Nov 28, 2026 | 1,609 |
| Nov 27, 2026 | 1,552 |
| Nov 26, 2026 | 1,270 |
| Nov 25, 2026 | 353 |
| Nov 24, 2026 | 32 |
| Nov 23, 2026 | 39 |
| Nov 22, 2026 | 39 |
| Nov 21, 2026 | 63 |
| Nov 20, 2026 | 343 |
| Nov 19, 2026 | 342 |
| Nov 18, 2026 | 338 |
| Nov 17, 2026 | 337 |
| Nov 16, 2026 | 326 |
| Nov 15, 2026 | 320 |
| Nov 14, 2026 | 288 |
| Nov 13, 2026 | 0 |
| Nov 12, 2026 | 0 |
Each point is npm's rolling 7-day download count.
Health Score
Composite score based on GitHub activity, stars, npm downloads, publish recency, dependency count, and package size.
Badge for your README
[](https://payloaddirectory.dev/plugins/1453964226-root)<a href="https://payloaddirectory.dev/plugins/1453964226-root"><img src="https://payloaddirectory.dev/badge/1453964226-root.svg" alt="Payload Directory"></a>README
Backup and restore for Payload CMS 3 on PostgreSQL: scheduled (cron) and on-demand backups to Vercel Blob or S3-compatible storage (AWS S3, Cloudflare R2, MinIO), an admin dashboard with per-collection preview, selective restore, and optional media bundling.
This is a Postgres port of
@trieb.work/payload-plugin-backup-mongodb
(MIT). The admin UI, endpoints, storage layer and task/progress model are kept;
the database engine was rewritten for Payload's Drizzle/Postgres adapter.
| MongoDB plugin | This plugin | |
|---|---|---|
| Adapter | @payloadcms/db-mongodb | @payloadcms/db-postgres, @payloadcms/db-vercel-postgres |
| Unit of backup | Mongo collection | Postgres table, grouped per Payload collection/global in the UI (posts, posts_locales, posts_rels, _posts_v, … toggle together) |
| Snapshot | collection by collection | one REPEATABLE READ READ ONLY transaction – all tables from the same instant |
| Serialization | EJSON | rows serialized by Postgres (json_agg) and restored with json_populate_recordset; numeric, bigint, jsonb, arrays, bytea, timestamps round-trip exactly |
| Restore | per collection, best effort | atomic by default (single transaction, rolled back if any table fails); FK-aware ordering, cycles and self references handled, sequences reset |
| Merge restore | upsert by _id / unique fields | per document: rows of documents in the backup replace the live ones (incl. their locales, arrays, blocks, rels); other documents are kept |
| Progress-row cleanup | TTL index | pruned on start-up and on each new task (> 30 min) |
| Settings field | skipMongoCollections | skipTables |
| Routes | /api/backup-mongodb/... | /api/backup-postgres/... |
Backups are not interchangeable between the two plugins.

The dashboard's Archives total is the combined size of the listed backup archives only, not the full Vercel Blob store. The listing is limited to 1,000 objects.

^3, Next.js 15/16, React 19, Node >=20.9@payloadcms/db-postgres or @payloadcms/db-vercel-postgres (the plugin uses
the adapter's pool and schemaName)BLOB_READ_WRITE_TOKEN) or S3
(BACKUP_STORAGE=s3)| Variable | Purpose |
|---|---|
BLOB_READ_WRITE_TOKEN | Vercel Blob token (backup target and/or media source) |
CRON_SECRET | Bearer secret for /api/backup-postgres/cron/* |
BACKUPS_TO_KEEP | Cron retention (default 10) |
BACKUP_STORAGE, BACKUP_S3_* | S3 target, see below |
PAYLOAD_BACKUP_ALLOWED_ROLES | Comma-separated roles (or *) that see the dashboard |
DATABASE_URI / DATABASE_URL / POSTGRES_URL | Only used to label backups with host/dbname (credentials are never included) |
pnpm add payload-plugin-backup-postgres
// payload.config.ts
import { postgresAdapter } from '@payloadcms/db-postgres'
import { backupPostgresPlugin } from 'payload-plugin-backup-postgres'
export default buildConfig({
db: postgresAdapter({ pool: { connectionString: process.env.DATABASE_URI } }),
plugins: [
backupPostgresPlugin({
// backupsToKeep: 14,
// access: (user) => user?.role === 'admin',
}),
],
})
Then:
push: false, i.e.
production): the plugin adds the backup-tasks and backup-settings
collections (backup_tasks, backup_settings,
backup_settings_skip_tables).
pnpm payload migrate:create add-backup-plugin && pnpm payload migratepnpm payload generate:importmap{
"crons": [
{ "path": "/api/backup-postgres/cron/run", "schedule": "0 3 * * *" }
]
}
<table>_locales, _rels, arrays and blocks are
replaced); documents created after the backup are kept. Live rows that collide
with a backup row on a unique key under a different id (e.g. a user re-created
with the same email) are evicted.users.avatar → media, media.owner → users) are written as NULL first and
linked in a second pass.max(id).{ atomic: false } to keep the
tables that succeeded.backup-tasks rows are never replaced while a tracked restore is running.Archive format: .json or .json.gz (no media; existing .json backups remain
supported) or .tar.gz (database.json + media/<pathname>), where
database.json is
{ format: "payload-plugin-backup-postgres", version: 1, schema, serverVersion, createdAt, tables: { [name]: { rowCount, rows } } }
and rows is the JSON text produced by Postgres.
Media bundling reads filename, sizes_*_filename (and prefix, if present)
from every upload-enabled collection, fetched from the Vercel Blob upload store.
Backups can be stored in Vercel Blob (default) or AWS S3. The S3 target also works with any S3-compatible store — Cloudflare R2, MinIO, etc. — because they share the same API; only the configuration differs, never the plugin code.
Select the target with BACKUP_STORAGE. When unset it stays vercel-blob, so
existing deployments are unaffected.
S3 is enabled when BACKUP_STORAGE=s3. Install the AWS SDK (declared as
optional peer dependencies, so Vercel-only installs don't pull it in):
pnpm add @aws-sdk/client-s3 @aws-sdk/lib-storage @aws-sdk/s3-request-presigner
| Variable | Required | Purpose |
|---|---|---|
BACKUP_STORAGE | yes | Set to s3. |
BACKUP_S3_BUCKET | yes | Target bucket name. |
BACKUP_S3_REGION | optional | Region. Falls back to AWS_REGION, then us-east-1. |
BACKUP_S3_ENDPOINT | optional | Custom endpoint for S3-compatible stores (R2, MinIO). Omit for AWS S3. |
BACKUP_S3_FORCE_PATH_STYLE | optional | Path-style addressing. Defaults to true when an endpoint is set (needed for MinIO and some R2 setups). |
BACKUP_S3_PREFIX | optional | Key namespace prepended to every object (for sharing a bucket). Backups still list/restore by their backups/… name. |
BACKUP_S3_ACCESS_KEY_ID | optional | Access key. Falls back to AWS_ACCESS_KEY_ID. Omit to use the AWS default credential chain (IAM roles, etc.). |
BACKUP_S3_SECRET_ACCESS_KEY | optional | Secret key. Falls back to AWS_SECRET_ACCESS_KEY. |
BACKUP_S3_SESSION_TOKEN | optional | Session token for temporary credentials. Falls back to AWS_SESSION_TOKEN. |
Credentials are optional: when omitted, the AWS SDK's default provider chain is used (environment, shared config, or instance/role credentials — recommended on AWS).
AWS S3
BACKUP_STORAGE=s3
BACKUP_S3_BUCKET=my-payload-backups
BACKUP_S3_REGION=eu-central-1
# Credentials via IAM role (recommended) or:
# BACKUP_S3_ACCESS_KEY_ID=...
# BACKUP_S3_SECRET_ACCESS_KEY=...
Cloudflare R2
BACKUP_STORAGE=s3
BACKUP_S3_BUCKET=my-payload-backups
BACKUP_S3_REGION=auto
BACKUP_S3_ENDPOINT=https://<account-id>.r2.cloudflarestorage.com
BACKUP_S3_FORCE_PATH_STYLE=true
BACKUP_S3_ACCESS_KEY_ID=<r2-access-key-id>
BACKUP_S3_SECRET_ACCESS_KEY=<r2-secret-access-key>
Backups are stored under the same backups/… keys (see
Blob naming), so listing and restore work identically across
targets. Downloads stream through the plugin's authenticated endpoint, so the
bucket does not need to be public.
Note on media: the "include media" option bundles files from your Payload Vercel Blob upload store (
BLOB_READ_WRITE_TOKEN). The configurable target above governs where backup archives live only; media is always read from and restored to the upload store, even whenBACKUP_STORAGE=s3.
After the first login as an admin user, the backup dashboard is available at
/admin/db-backups. Day-to-day tasks — create, download, restore, delete,
schedule — are managed on this dedicated page.
Backups receive sequential numbers starting at #1. Existing archives are numbered oldest first, and a number is never reused after its backup is deleted. Each Payload database has its own counter, kept in the database and excluded from backup restores.
Who can see it? The visibility rules, in precedence order:
access function, it wins (see
Plugin options).PAYLOAD_BACKUP_ALLOWED_ROLES is set, it is used as a
comma-separated allow-list of role slugs (case-insensitive). Use * for "any
authenticated user". Example:
PAYLOAD_BACKUP_ALLOWED_ROLES=admin,superadmin.role whose slug is
admin see the dashboard; projects that don't use a roles field at all get
the dashboard for any authenticated user..tar.gz archive. Manual backups are not
auto-pruned; use them as checkpoints before migrations.
Restore opens a preview of the archive before any write. You can restore
everything, cherry-pick collections, or skip media from .tar.gz when you only
need database rows. Restoring from a different host or database is supported;
filters help when cloning production into staging.

Retention, storage token, and cron collection skip list live in one modal:

vercel.json is present, the plugin can show a
human-readable cron description (via
cronstrue).BACKUP_STORAGE=vercel-blob) so backups can live in a different
store than media. The UI can validate the token and optionally copy existing
backups/* objects to the new store. For S3, configure the target bucket via
environment variables.type BackupPluginOptions = {
/**
* Set to `false` to disable the plugin (no collections, endpoints, or admin UI).
* Omit or leave unset to keep the plugin active.
*/
enabled?: boolean
/** Default cron retention when no value is stored in settings. Falls back to `BACKUPS_TO_KEEP` or `10`. */
backupsToKeep?: number
/**
* Custom access check for admin routes and the dashboard. Overrides the
* `PAYLOAD_BACKUP_ALLOWED_ROLES` env var when provided.
*
* Default (env-based): see the `PAYLOAD_BACKUP_ALLOWED_ROLES` entry in the
* environment variables table. When neither is configured, the check falls back
* to a role with slug `admin`, or allows any authenticated user in projects
* without a `roles` field.
*/
access?: (user: Record<string, unknown> | null) => boolean
}
All routes are served by Payload’s /api/[...slug] handler under
/api/backup-postgres/…. The backup-postgres prefix avoids clashing with
a collection slug. The admin UI uses the same URLs; use the exported
backupPluginPublicApiPaths helper in client code.
CRON_SECRET)GET /api/backup-postgres/cron/run # enqueue a cron backup
GET /api/backup-postgres/cron/list # list backups
POST /api/backup-postgres/cron/restore # body: { "url": "https://…" }
Authorization: Bearer <CRON_SECRET>
pollSecret for /task/:id where applicable)| Method | Path |
|---|---|
POST | /api/backup-postgres/admin/manual |
POST | /api/backup-postgres/admin/restore |
POST | /api/backup-postgres/admin/backup-preview |
POST | /api/backup-postgres/admin/restore-preview |
POST | /api/backup-postgres/admin/delete |
GET | /api/backup-postgres/admin/backup-download |
GET | /api/backup-postgres/admin/task/:id |
GET / POST | /api/backup-postgres/admin/settings |
POST | /api/backup-postgres/admin/validate-blob-token |
backups/{type}---{dbName}---{hostname}---{collectionCount}-{timestampMs}.{json|tar.gz}
type: cron or manual (and legacy-style labels where applicable).dbName / hostname: derived from your Postgres connection string
(host/dbname) and public server URL; URL-encoded in the name.collectionCount + timestampMs: sort key for listing; legacy blob names are
still supported.A validation step probes the bucket and records whether the store behaves as public or private. New uploads use the right access mode. Restore and preview flows handle both.
To keep backups in a different Vercel Blob project than media (when
BACKUP_STORAGE=vercel-blob), open Backup settings in the admin, paste a
dedicated BLOB_READ_WRITE_TOKEN, validate, and optionally migrate existing
backups/* objects to the new store before switching. For S3, the target is
controlled entirely by environment variables.
The integration suite boots a real Payload instance on Postgres (localized
fields, drafts/versions, blocks, arrays, hasMany relationships, a
self-referencing FK, a users ↔ media FK cycle, a global, and a numeric
beyond double precision) and runs backup → mutate → restore round-trips against
an in-memory storage adapter.
createdb payload_test # or: TEST_DATABASE_URL=postgres://... pnpm test
pnpm test
The test drops and recreates the public schema of the target database. Point
it at a throwaway database.
MIT. Based on @trieb.work/payload-plugin-backup-mongodb by trieb.work (MIT).
Topics
payload plugin backup mongodb
MongoDB backup and restore for Payload with Vercel Blob or S3-compatible storage and an admin dashboard
5484/wk8v3
seed
Seed an Atomic Payload database from the admin dashboard with a button and a POST endpoint
6033/wk37v3
payload plugin janitor
Find orphaned files, missing uploads and unused documents, then delete only what you approve
5610/wk7v4
cloud storage
Store Payload uploads in third-party cloud storage through a generic adapter interface
1001.0M/wk46.1kv3 v4
payload upstash
Upstash Redis key-value adapter for Payload's built-in KV store
82333/wk7v3 v4
payload kv
Store counters, feeds and expiring data in Redis or KV stores while querying them as normal Payload fields
771.4k/wk0v3 v4