Skip to main content
POST
/
api
/
v1
/
databases
/
{id}
/
backups
/
restore
Restore from file
curl --request POST \
  --url https://api.example.com/api/v1/databases/{id}/backups/restore
Uploads a pg_dump file and restores it into the target database. Use this when migrating from another host or restoring from a locally stored backup.
This is a destructive operation. All current data in the database will be replaced with the uploaded file’s contents. This cannot be undone.

Path parameters

ParameterTypeDescription
iduuidDatabase ID

Request body

multipart/form-data with a single file field.

Supported file formats

ExtensionDescription
.sql.gzCompressed SQL dump (what DBHost produces)
.sqlPlain SQL text dump
.dumppg_dump custom format (pg_dump --format=custom)
.backuppg_dump custom format (alternate extension)
Maximum file size: 512 MB.

Example

curl -X POST \
  -H "Authorization: Bearer dbh_your_api_key_here" \
  -F "file=@./mybackup.sql.gz" \
  https://dbhost.app/api/v1/databases/550e8400-e29b-41d4-a716-446655440000/backups/restore

Response

200 OK
{
  "message": "Database 'mydb' restored from 'mybackup.sql.gz'"
}

Errors

StatusCodeDescription
400INVALID_REQUESTRequest is not multipart/form-data
400MISSING_FILENo file field in form data
400INVALID_FILENAMEFilename doesn’t match a supported format
401UNAUTHORIZEDMissing or invalid API key
404DATABASE_NOT_FOUNDDatabase doesn’t exist, isn’t owned by this user, or isn’t in scope for this key
413PAYLOAD_TOO_LARGEFile exceeds the 512 MB size limit
503AGENT_ROUTE_UNAVAILABLEThe VPS agent doesn’t support restore yet (needs update)
500AGENT_ERRORThe VPS agent failed to restore from the uploaded file