# Restoring files, mail and databases

> Get back a single file, a mailbox, one mail folder, a database, a whole account or a deleted subscription from the hourly history or an archive, next to the original or over it.

Source: https://www.berthpanel.app/library/restoring-data/ · Category: backup · Updated: 2026-10-29

Most restores are small: one overwritten `wp-config.php`, a mail folder a customer emptied by accident, a database before a failed plugin update. Berth lets you, and your customers, restore exactly that piece from the hourly history or from an archive, without touching the rest of the account. This article covers where restores come from, the choices you get, searching and comparing moments, and downloads.

## Where a restore comes from

| Source | Granularity | Best for |
|---|---|---|
| **History** on this server | a moment every hour by default, down to every 15 minutes | recent mistakes: "as it was at 14:00" |
| **Archives** on this server | one per schedule run, usually nightly | a known-good state from a previous night |
| **External places** (S3, NAS) | per schedule | anything older, or when the server's own copies are gone |

Snapshots on an external deduplicated place are fetched into the subscription's history first, after which they work exactly like local moments. On the history page use *Fetch from the external copy*, on the backups page *Fetch into the history*, or the CLI:

```bash
berth backup location pull <place-id> --sysuser acme
berth backup history pull --sysuser acme
```

Only moments from after the subscription was created come back, never those of an earlier subscription that used the same system user. Loose archives in S3 come back with `berth backup fetch`.

For databases there is also [point-in-time restore](https://www.berthpanel.app/library/point-in-time-restore/), which replays the binary log or WAL to any moment within its window.

## The hourly history

Next to full archives, Berth keeps a **history** per subscription: a restic repository on this server with a moment every hour by default. Each moment holds the webspaces, the Maildirs and a dump of every database. restic skips unchanged files by their metadata and stores each piece of data only once, compressed, so a round with few changes takes seconds and a few megabytes. Caches, temporary folders and the output of backup plugins (for example `wp-content/cache` and UpdraftPlus archives) are left out.

The default retention keeps the newest moment of each of the last 48 hours, 14 days, 8 weeks and 6 months. The work runs at the lowest CPU and IO priority, and a disk guard skips a round with a notice rather than fill the disk.

The history is configured as a schedule to the place *History on this server*. Per subscription it can be switched off on the history page under *Settings*, optionally removing the existing moments. A customer can capture a moment by hand with *Capture a moment now*, for example before a large change.

## Restoring from the history

1. Open the domain → *Backups* → *History*.
2. Pick a moment on the timeline (today, yesterday, this week, earlier).
3. Browse *Websites*, *Mail* or *Databases*. Folder sizes are shown as they were at that moment.
4. Choose **Restore…** on a file, folder, mailbox, mail folder, message or database, and how:

| What | *Next to what is there now* (default) | *Instead of what is there now* |
|---|---|---|
| File or folder | in `herstel/<YYYYMMDD-HHMM>/` in the webspace | replaces the current one |
| Whole website | in `herstel/<time>/` | the whole webspace (`herstel/` stays) |
| Mailbox or mail folder | in a folder `Hersteld-<time>` | *Only missing messages back* or *Exactly as it was* |
| Single messages | in `Hersteld-<time>` | back in their own folder |
| Database | a new database with its own password, shown once | emptied and restored |
| The whole subscription | everything next to it | everything exactly as it was (*Restore everything…*) |

Restoring next to the original never loses anything: you look first, then move what you need. Overwriting asks you to type `terugzetten` (restore) first, and when [four-eyes approval](https://www.berthpanel.app/library/audit-trail-and-approvals/) is enabled it goes past a second administrator.

To find a lost message, open the folder, search by subject or sender, tick the message and restore it into its folder.

```bash
berth backup history restore --sysuser acme --at "2026-10-28 14:00" \
  --domain acme.nl --path httpdocs/wp-config.php            # next to it
berth backup history restore --sysuser acme --at latest \
  --domain acme.nl --path httpdocs/wp-config.php --over     # over it
berth backup history restore --sysuser acme --at "14:00" \
  --mailbox info@acme.nl --folder INBOX --mode merge        # alongside | merge | replace
berth backup history restore --sysuser acme --at "2026-10-27 09:00" \
  --database acme_wp                                        # as a new database
berth backup history restore --sysuser acme --at "2026-10-27 09:00" --all --over
```

`--at` accepts `latest`, a moment ID (or its first characters) or a time; a time picks the last moment at or before it.

## Searching across moments

*Search* answers "when did this file exist, and when did it disappear?". Type part of a name or path (`wp-config`, `uploads/photo`, `*.php`), optionally with a website and a period. Per hit you see in which moments it existed, how many versions there were, and the first moment without it. Each version can be viewed, downloaded or compared with the previous one.

```bash
berth backup history find --sysuser acme --query wp-config --since 2026-10-01
```

## Comparing two moments

*Diff* shows what changed between two moments: files and folders added, removed or changed, the busiest folders, per mailbox the number of messages added and removed, and which database dumps changed. For a text file you can see the line-by-line difference as a unified diff. This is often the fastest way to find what a compromised plugin changed, or which upload removed a folder.

```bash
berth backup history diff --sysuser acme --from "13:00" --to "14:00"
berth backup history diff --sysuser acme --from "13:00" --domain acme.nl \
  --path httpdocs --change removed
berth backup history diff --sysuser acme --from "13:00" --domain acme.nl \
  --file httpdocs/wp-config.php
```

## Restoring from an archive

Open an archive from *Backups* (or the domain's *Backups* page) and choose what to restore:

| What | Options |
|---|---|
| **Files and folders** | one or more at a time (*Choose files*), next to the original in `herstel/<archive>/` or over it; or whole webspaces |
| **Mailboxes** | only missing messages back (merge), into a folder `Hersteld-<archive>` next to it, or exactly as it was. A deleted mailbox comes back with its old password, quota and rules |
| **Databases** (MariaDB and PostgreSQL) | into a new database next to it, with its own user, or over the existing one. A deleted database comes back with the same users and passwords |
| **Container volumes** | per volume, exactly the state of the archive |
| **The whole account** (*Restore the whole account*) | domains, mailboxes, aliases and databases that were removed since come back, and all content gets the state of the archive |

Databases are never restored with more rights than the customer has.

```bash
berth backup overview --q acme.nl
berth backup restore-items --sysuser acme --name 20261028-013000.tar.gz \
  --mailboxes info@acme.nl --mail-mode merge \
  --databases acme_wp --db-mode alongside
berth backup restore-items --sysuser acme --name 20261028-013000.tar.gz \
  --files acme.nl:httpdocs/wp-content/uploads --files-alongside
berth backup snapshot --sysuser acme --name 20261028-013000.tar.gz   # whole account
```

### A deleted subscription

Archives of deleted subscriptions stay under *Backups* for the configured period (30 days by default, pinnable). Restoring the whole account from such an archive rebuilds the subscription with its domains, mail, databases and content: open the archive and choose *Restore the whole account*, or use `berth backup snapshot`.

The history of a deleted subscription can be browsed and downloaded by an administrator, but deliberately not restored into another subscription: one wrong choice would put the previous owner's data in someone else's account.

## Downloads

Instead of restoring, you can download:

- a single file as it was;
- a folder as a zip;
- a single message as `.eml`, or a mail folder or mailbox as a zip of `.eml` files;
- a database dump as `.sql.gz`.

Downloads stream straight from the backup to the browser without being unpacked on disk first. They require a recent sign-in.

```bash
berth backup history dump --sysuser acme --at "14:00" --domain acme.nl \
  --path httpdocs/wp-content/uploads --zip --out uploads.zip
berth backup history dump --sysuser acme --database acme_wp --out acme_wp.sql.gz
berth backup files download --name 20261028-013000.tar.gz --domain acme.nl \
  --path httpdocs --zip --out site.zip
```

## Who can do what

- **Customers and resellers** restore and download their own data from the history and from archives, within their own subscriptions.
- **Administrators** can do everything, including fetching external snapshots and restoring deleted subscriptions.
- **Auditors** see timelines, names, times and counts, but download nothing and see no mail subjects, senders or line diffs.

Line diffs and overwrite restores are recorded in the [audit trail](https://www.berthpanel.app/library/audit-trail-and-approvals/).

### Archives with the customer's own key

If a customer set their own OpenPGP key, nobody but the customer can read the archive. They download it, decrypt it (`gpg --decrypt archive.tar.gz.gpg > archive.tar.gz`) and upload it again on the domain's *Backups* page with *Upload*. The upload is removed automatically after a day.

## Related

- [How backups work](https://www.berthpanel.app/library/backups-overview/)
- [Restore tests](https://www.berthpanel.app/library/restore-tests/)
- [Disaster recovery](https://www.berthpanel.app/library/disaster-recovery/)
- [Mailboxes](https://www.berthpanel.app/library/mailboxes/)
- [Databases](https://www.berthpanel.app/library/databases/)
