Skip to main content
The Backups API allows superusers to create, download, and restore full database backups. All backup endpoints require superuser authentication.
All backup operations require superuser authentication.

List backups

Retrieve a list of all available backup files.
Authentication: Superuser required

Response

Returns an array of backup file information.
string
Backup file name/key
number
File size in bytes
string
Last modification timestamp (ISO 8601)

Create backup

Create a new backup of the entire database.
Authentication: Superuser required

Request body

string
required
Backup file name (must match pattern: [a-z0-9_-]+\.zip)

Response

Returns 204 No Content on success.
If no name is provided, PocketBase generates one automatically based on the current timestamp.

Validation

  • Name must be 1-150 characters
  • Only lowercase letters, numbers, hyphens, and underscores allowed
  • Must end with .zip
  • Must be unique (cannot overwrite existing backup)
  • Only one backup/restore operation can run at a time

Common errors

Download backup

Download a backup file.
string
required
The backup file key/name
string
required
Superuser file token (see Generate file token)
Authentication: File token required (superuser only)

Response

Returns the backup file as a ZIP archive.
Backup downloads use file tokens instead of auth tokens for security. The token must belong to a superuser account.

Delete backup

Delete a backup file.
string
required
The backup file key/name to delete
Authentication: Superuser required

Response

Returns 204 No Content on success.

Common errors

Restore backup

Restore the database from a backup file.
string
required
The backup file key/name to restore
Authentication: Superuser required

Response

Returns 204 No Content on success. The server will restart after restoring.
Restoring a backup will:
  1. Replace the current database with the backup data
  2. Restart the PocketBase application
  3. Close all active connections
This operation cannot be undone. Always create a current backup before restoring.

Restore process

  1. Request is validated
  2. Response is sent (204 No Content)
  3. After ~1 second delay, restore begins
  4. Database is replaced with backup data
  5. Application automatically restarts

Common errors

Upload backup

Upload an external backup file to the server.
Authentication: Superuser required

Request

Use multipart/form-data to upload the backup file.
file
required
The backup ZIP file to upload

Response

Returns 204 No Content on success.
The uploaded backup must be a valid PocketBase backup ZIP file. Invalid or corrupted files will be rejected.

Backup contents

PocketBase backups are ZIP archives containing:
  • Database - SQLite database file (data.db)
  • Storage - All uploaded files from pb_data/storage/
  • Metadata - Backup information and checksums

Backup structure

Automated backups

The Backups API is designed for manual operations. For automated backups:
  1. Create a scheduled task/cron job
  2. Call POST /api/backups with superuser auth
  3. Optionally download and store externally

Example backup script

Storage locations

Backups are stored in the location configured in your PocketBase settings:
  • Local storage: pb_data/backups/
  • S3-compatible: Configured S3 bucket
When using S3 storage, backups may not be immediately available due to eventual consistency. Wait a few seconds after creation before attempting to list or download.

Best practices

  1. Regular backups - Schedule automated backups daily or more frequently
  2. Off-site storage - Download and store backups externally
  3. Test restores - Periodically test backup restoration
  4. Backup before changes - Always backup before schema changes or major updates
  5. Retention policy - Delete old backups to manage storage

Performance considerations

  • Backup creation locks the database briefly
  • Large databases may take several minutes to backup
  • Only one backup/restore operation can run at a time
  • Restore operations require application restart

Common errors