# POST /backups/restore

First published 3 Oct 2026 (release 0.1.0) · Unchanged since publication

UrbeStack release 0.2.35 API operation in the backups group.

Queue a restore job for a customer backup archive

- Who may call it: administrator
- Token scope, any of: backups, all
- Answers: 202 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

- [urbestack-restore](https://urbestack.com/docs/commands/urbestack-restore.md): Restores a customer from an UrbeStack archive or restores a whole backup day folder onto a fresh installation.

## Request body

JSON, the type [RestoreRequest](https://urbestack.com/docs/api/types/RestoreRequest.md).

- `name` (Username, required): A username consists of lowercase letters, digits and underscores. For the user role, it also serves as the system account name.
- `database` (string): Name of the database to restore when scope is database.
- `day` (string, 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.
- `file` (string): 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.
- `scope` (string, 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

Set $API to the base URL and $TOKEN to the token, as the [API overview](https://urbestack.com/docs/api.md) shows.

```
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

- 400: A database name is letters, digits and underscores
- 400: A day is named YYYY-MM-DD
- 400: A new job is queued or running
- 400: An archive is an absolute path ending in .tar.gz
- 400: Invalid <what>: 
- 400: Invalid username: 2 to 32 lowercase letters, digits or underscores, starting with a letter
- 400: Job parameters must be an object
- 400: One of day and file, not both
- 400: The database scope names the database
- 400: The scope is one of 
- 400: Unknown job type
- 400: Username '<value>' is reserved
- 401: Authentication required
- 403: A 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
- 403: Insufficient privileges
- 404: No archive of <name> for <day> in 
- 404: User '<user>' not found
