Get your free beta license ↗
API operation · backups group
POST

/backups/restore

First published 3 Oct 20260.1.0Unchanged since publication

Queue a restore job for a customer backup archive

Who may call it
AdministratorResellerCustomer
Token scope, any of
backupsall
Answers202 Accepted

UrbeStack queues a job of type restore for the customer specified in name and returns 202 with the queued job in the job field. The job reports progress and stops at the first failure, listing the steps it completed. The token requires the backups scope. UrbeStack returns 403 to callers without administrator privileges.

Set day to YYYY-MM-DD to select the customer's archive from the backup day folders. If the backup directory exists and is readable at submission, UrbeStack returns 404 when the archive is missing. Otherwise, the job checks for the archive when it runs.

Only a plugin token can supply a nonempty file. Other tokens receive 403. At the shell, use urbestack-restore --file to restore an archive outside the day folders. With a plugin token, file must be an absolute path ending in .tar.gz. After the leading slash, the path may contain word characters, periods, slashes, @, + and hyphens. UrbeStack returns 400 for an invalid path or if you also supply a non-null day. When the job runs, it requires a root-owned regular file, rejects symbolic links and checks that the archive names the customer specified in name. Restore requires an UrbeStack customer archive with a matching schema version.

The default scope is everything, which restores account records, the home directory including mail, and every database. The files scope restores the home directory excluding mail. The mail scope restores mailbox contents, the database scope loads one dump, and the records scope restores only account records. With scope set to database, database must name a database in the archive and contain 1 to 64 ASCII letters, digits or underscores. UrbeStack returns 400 for an invalid day or scope, or for a missing or malformed database with the database scope. The job checks that the requested dump exists.

If the customer account is missing, UrbeStack recreates it from account.json before restoring the selected scope. Archived files and mail replace matching files in the home directory, and archived account records replace matching records. Files and records absent from the archive are preserved. Each database dump replaces the tables it contains through its DROP TABLE statements. UrbeStack recreates missing databases, database users and grants from the archive.

As a command

Run as root on the server

Request body

JSON ·RestoreRequest· 5 fields
nameUsernameRequired
A username consists of lowercase letters, digits and underscores. For the user role, it also serves as the system account name.
databasestring
Name of the database to restore when scope is database.
daystring, matching ^\d{4}-\d{2}-\d{2}$
Server-local date in YYYY-MM-DD format. To restore the customer's nightly archive from that day's folder, specify day instead of file.
filestring
Absolute path ending in .tar.gz to the customer's UrbeStack archive, retrieved from the plugin's own storage. The job requires a regular file owned by root, follows no symbolic links, and rejects archives that belong to another customer. Specify exactly one of day and file. Only plugin keys can use file. UrbeStack sessions and tokens receive 403 and can select the archive by day. To restore an archive by path from the shell, use urbestack-restore --file.
scopestring, one of everything, files, mail, database, records
Restore scope. The everything scope restores records, the home directory including website files and mail, and all databases. The files scope restores the home directory excluding mail, mail restores mailboxes, database restores one dump selected by the database field, and records restores only records.

Example

See the API overview for how to set $API and $TOKEN.
Request
curl -sS -X POST "$API/backups/restore" \
  -H "Authorization: Bearer $TOKEN" \
  -H "Content-Type: application/json" \
  -d '{
    "database": "alice_shop",
    "day": "2026-09-09",
    "file": "urbestack-panel-20260909T101500Z.json.enc",
    "name": "alice",
    "scope": "everything"
  }'
Response · 202 Accepted
{
  "job": {
    "created_at": "2026-09-09T10:15:00Z",
    "created_by": 1,
    "created_by_name": "text",
    "dismissed_at": "text",
    "finished_at": "2026-09-09T10:15:04Z",
    "id": 1,
    "lane": "short",
    "log": "",
    "params": {},
    "progress": 100,
    "result": {},
    "started_at": "2026-09-09T10:15:01Z",
    "status": "queued",
    "type": "rebuild",
    "usual_seconds": 1
  }
}

Errors

17 errors, each a status and a sentence
400A database name is letters, digits and underscores
400A day is named YYYY-MM-DD
400A new job is queued or running
400An archive is an absolute path ending in .tar.gz
400Invalid <what>:
400Invalid username: 2 to 32 lowercase letters, digits or underscores, starting with a letter
400Job parameters must be an object
400One of day and file, not both
400The database scope names the database
400The scope is one of
400Unknown job type
400Username '<value>' is reserved
401Authentication required
403A file outside the day folders is restored at a shell with urbestack-restore --file, or by a plugin through its key; the panel's own sessions and tokens name days
403Insufficient privileges
404No archive of <name> for <day> in
404User '<user>' not found
Generated from release 0.2.35 (current) · the API’s own descriptionThis entry has been unchanged since it was first published in release 0.1.0 on 3 Oct 2026.
urbestack.com/docs/api/post-backups-restore/