List backups
Retrieve a list of all available backup files.Response
Returns an array of backup file information.Backup file name/key
File size in bytes
Last modification timestamp (ISO 8601)
Create backup
Create a new backup of the entire database.Request body
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
| Code | Description |
|---|---|
| 400 | Invalid name format or backup already in progress |
| 401 | Not authenticated as superuser |
Download backup
Download a backup file.The backup file key/name
Superuser file token (see Generate file token)
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.The backup file key/name to delete
Response
Returns 204 No Content on success.Common errors
| Code | Description |
|---|---|
| 400 | Backup is currently in use (being created or restored) |
| 404 | Backup file not found |
Restore backup
Restore the database from a backup file.The backup file key/name to restore
Response
Returns 204 No Content on success. The server will restart after restoring.Restore process
- Request is validated
- Response is sent (204 No Content)
- After ~1 second delay, restore begins
- Database is replaced with backup data
- Application automatically restarts
Common errors
| Code | Description |
|---|---|
| 400 | Another backup/restore is in progress or backup file not found |
| 500 | Restore operation failed |
Upload backup
Upload an external backup file to the server.Request
Usemultipart/form-data to upload the backup file.
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:- Create a scheduled task/cron job
- Call
POST /api/backupswith superuser auth - 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
- Regular backups - Schedule automated backups daily or more frequently
- Off-site storage - Download and store backups externally
- Test restores - Periodically test backup restoration
- Backup before changes - Always backup before schema changes or major updates
- 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
| Code | Description |
|---|---|
| 400 | Invalid backup name, operation in progress, or missing file |
| 401 | Not authenticated as superuser |
| 403 | File token doesn’t belong to superuser |
| 404 | Backup file not found |
| 500 | Backup/restore operation failed |