Skip to main content
POST
/
api
/
backup
Backup Operations
curl --request POST \
  --url https://api.example.com/api/backup \
  --header 'Content-Type: application/json' \
  --data '
{
  "description": "<string>",
  "includeDocuments": true
}
'
{
  "backupId": "<string>",
  "filename": "<string>",
  "size": 123,
  "cloudinaryUrl": "<string>",
  "createdAt": "<string>",
  "description": "<string>"
}
Manage database backups and exports.

Create Backup

POST /api/backup/create

Create a new backup of the database and upload it to Cloudinary.

Authentication

Required. Only Admin role can create backups.

Request Body

description
string
Optional description for the backup
includeDocuments
boolean
default:"true"
Whether to include uploaded documents in the backup

Response

backupId
string
Unique backup identifier
filename
string
Backup file name
size
number
Backup file size in bytes
cloudinaryUrl
string
URL to backup file on Cloudinary
createdAt
string
ISO timestamp of backup creation
description
string
Backup description

Example Request

cURL
curl -X POST "https://api.millenium-potters.com/api/backup/create" \
  -H "Authorization: Bearer YOUR_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{
    "description": "Pre-deployment backup",
    "includeDocuments": true
  }'

Example Response

{
  "backupId": "backup_2026-03-11T12-00-00-000Z",
  "filename": "backup_2026-03-11T12-00-00-000Z.json",
  "size": 15728640,
  "cloudinaryUrl": "https://res.cloudinary.com/millenium/backups/backup_2026-03-11.json",
  "createdAt": "2026-03-11T12:00:00Z",
  "description": "Pre-deployment backup"
}
Backup creation may take several minutes depending on database size. The operation runs asynchronously.

List Backups

GET /api/backup/list

Retrieve a list of all available backups.

Authentication

Required. Only Admin role can list backups.

Response

{
  "backups": [
    {
      "backupId": "backup_2026-03-11T12-00-00-000Z",
      "filename": "backup_2026-03-11T12-00-00-000Z.json",
      "size": 15728640,
      "cloudinaryUrl": "https://res.cloudinary.com/millenium/...",
      "createdAt": "2026-03-11T12:00:00Z",
      "description": "Pre-deployment backup"
    }
  ],
  "total": 15,
  "cloudinaryStats": {
    "totalSize": 235929600,
    "count": 15
  }
}

Download Backup

GET /api/backup/download/:backupId

Download a specific backup file.

Authentication

Required. Only Admin role can download backups.

Path Parameters

backupId
string
required
Backup identifier

Response

Returns the backup file as a downloadable JSON file.

Delete Backup

DELETE /api/backup/:backupId

Delete a backup from Cloudinary.

Authentication

Required. Only Admin role can delete backups.
Deleting a backup is permanent and cannot be undone. Ensure you have other backup copies before deleting.

Restore from Backup

Backup restoration is a critical operation that should only be performed during maintenance mode. See the Backups Guide for detailed restoration procedures.
Restoration is typically done manually:
  1. Enable maintenance mode
  2. Download the backup file
  3. Use Prisma to restore the database
  4. Verify data integrity
  5. Disable maintenance mode

Automatic Backups

The system uses CockroachDB’s built-in backup features:
  • Hourly backups automatically created
  • 30-day retention period
  • Point-in-Time Recovery (PITR) available
The manual backup API is for additional application-level backups stored in Cloudinary.

Error Responses

Missing or invalid authentication token.
User does not have Admin permissions for backup operations.
Backup creation or upload failed. Common causes:
  • Cloudinary storage quota exceeded
  • Database connection issues
  • Insufficient disk space
Specified backup ID does not exist.

See Also

Build docs developers (and LLMs) love