# POST /users/{name}/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 customer restore from an on-demand or nightly backup archive

- Who may call it: administrator, reseller, customer
- Token scope, any of: backups, all
- Answers: 202 Accepted

Use own for an on-demand archive or day for a nightly archive. A nonempty own takes precedence over day. The archive must be an UrbeStack customer archive with a matching schema version. Choose one scope. The default, everything, restores account records, the home directory including mail, and every database in the archive. Use files for the home directory excluding mail, mail for mailbox contents, database for one database dump, or records for account records. With database scope, the named database must have a dump in the archive.

The API returns 400 if the target account is an administrator, neither archive selector is supplied, the selected value has an invalid format, own ends in .part, scope is invalid, or database is missing or invalid for database scope. The API returns 409 if a restore or on-demand backup for the customer is already queued or running. For customers and resellers, the API returns 403 if the package excludes on-demand backups or if day is selected while either backups.enabled or backups.nights_for_customers is off. Only an administrator can restore a suspended account.

For a customer or reseller, UrbeStack treats the archive as untrusted and restores into the account specified by name, regardless of the account named in the archive. An archive selected by own must be a regular file owned by the customer. Symbolic links are refused. UrbeStack extracts files and mail with tar running as the customer and loads dumps as the customer's phpMyAdmin user, rewriting every DEFINER to that user so the restore can access only the customer's databases.

Customer restores validate records using the same rules as manual changes. For existing domains, they can restore DNS records, mail accounts and their passwords, forwarders, filters, autoresponders, mailing lists, customer-configurable mail settings and FTP accounts. They can also restore databases with their users and grants, SSH keys, backup exclusions and cron jobs. The job result identifies omissions involving domains, domain settings, administrator-only settings and the customer account itself.

Administrator restores run as root and warn if the archive is owned by another user. An administrator restore using own requires the archive to name the specified customer. It recreates missing databases, database users and grants from the archive, and dumps replace the tables covered by their DROP TABLE statements. Restored files and records are applied over the existing account, replacing matching entries.

The response contains the queued restore job in job. The job reports progress, stops at the first failure and lists the steps completed before it.

## 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.

## Parameters

- `name` (path, Username, required)

## Request body

JSON.

- `database` (string): Name of the database to restore, required when scope is database. Use 1 to 64 ASCII letters, digits or underscores.
- `day` (string, matching ^\d{4}-\d{2}-\d{2}$): Date of the server's nightly backup in YYYY-MM-DD format.
- `own` (string): Filename of a completed archive in the customer's backups/ directory. It starts with an ASCII letter or digit, followed by up to 200 ASCII letters, digits, dots, underscores or hyphens, and ends in .tar.gz.
- `scope` (string, one of everything, files, mail, database, 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/users/alice/backups/restore" \
  -H "Authorization: Bearer $TOKEN" \
  -H "Content-Type: application/json" \
  -d '{
    "database": "alice_shop",
    "day": "2026-09-09",
    "own": "text",
    "scope": "everything"
  }'
```

Response, 202 Accepted:

```
{
  "job": {}
}
```

## Errors

- 400: <f> is still being written
- 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 administrator has no home to restore into
- 400: An archive is named <user>-<date>-<time>.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: Name the archive: own, one of the customer's, or day, a night of the server
- 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: Nightly backups aren't available to customers on this server. Restore from one of the account's on-demand backups instead.
- 403: The package <p.name> does not include <SWITCH_WHAT>{<switch>}
- 404: User '<user>' not found
- 409: A restore or a backup of <name> is already <j.status> (job <j.id>); one at a time
