Unicat API Reference

Up - API Reference - Home


/api/p/<project gid>/backups/restore

Requires JWT.

Restores a backup of the project database. You cannot restore version 0.

Processing is done as a job running in the background, it may be incomplete when you receive the response. Job progress can be queried using the returned job.token.

Request

POST /api/p/<project gid>/backups/restore
Authorization: Bearer <JWT>

{
    "version": 2
}

version specify the backup version to restore

Success response

Authorization: <JWT>

{
    "success": true,
    "result": {
        "project": "<project gid>",
        "version": 2,
        "last_restored": 1613565541.4195538,
        "job.token": "06715cb7-4dfa-4ec1-bad4-c136ddbf80d9",
    },
    "data": {}
}

result

project the current project.
version the version that is being restored.
last_restored is a server-side timestamp of the backup file that is used for this restore.
job.token the job token to look for in sync events.

Job status

Look for the job.token in sync events to find status updates on the operation. The sync event looks like this:

{
    "type": "cc",
    "cursor": <cursor>,
    "action": "UPDATE",
    "data_type": "jobs",
    "data_key": "7c136ddb-4dfa-4ec1-bad4-15067cbf80d9",
    "data": {
        "project_gid": "<project_gid>",
        "job": "restore_project",
        "status": "processing",
        "info": {
            "total": 120,
            "remaining": 26
        },
        "created_on": 1613565541.4195538,
        "updated_on": 1613565543.2836412,
    }
}

status can be either queued, rejected, processing, or done.

Error responses

401 Unauthorized - missing or expired JWT
403 Forbidden - not a member of this project
422 Unprocessable entity - backup version invalid
1003 Process error - restore failed

HTTP/1.1 422 Unprocessable entity

{
    "success": false,
    "result": {
        "code": 1003,
        "message": "Process error",
        "info": {
            "process": "restore"
        }
    },
    "data": {}
}