Skip to content

useMongocampMaintenance ​

Backups and migrations of the server (MongoCamp 2.11), administrators only (403 otherwise).

ts
const { listBackups, runBackup, listMigrations, runMigrations } = useMongocampMaintenance()
const backups = await listBackups()          // BackupRow[] newest first: id, createdAt, database, coreVersion?, collections, documents, names
const outcome = await runBackup()            // { backup } — or { refused: 'running' } while another instance writes one (409)
const migrations = await listMigrations()    // MigrationRow[] in id order: id, description, state, defined, reversible, startedAt, durationMs?, error?
const applied = await runMigrations()        // the ids that ran; a failing migration rejects with the server's message
await runMigrations('2026-12-04-x')          // up to and including that id

Reads time out after 15 s, a backup or a migration run after 120 s. The rows come from utils/maintenance.ts (backupRows, migrationRows, runnableCount — what Run pending would run: pending and failed). Restoring a backup has no API — it is the server command mongocamp restore.

MongocampMaintenance is the ready-made page.

Released under the MIT License.