# Backing up to your own NAS

> Send the encrypted external copy to a Synology, Ugreen or TrueNAS with a downloadable package that runs an append-only rest-server, so the server itself can never delete its backups.

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

A NAS at the office or at home makes a good external place: the data stays on hardware you own, and with append-only storage nobody who takes over the hosting server can delete the backups. Berth sets this up with a **downloadable package** for your NAS: one compose file with a restic rest-server, a certificate that Berth pins, and a cleanup task that runs on the NAS itself.

The NAS becomes an external deduplicated place, with the same functions as any other: encrypted snapshots, restore tests, fetching snapshots back to the server and full [disaster recovery](https://www.berthpanel.app/library/disaster-recovery/). For the general model, see [How backups work](https://www.berthpanel.app/library/backups-overview/).

## How it protects your backups

What runs on the NAS (all defined in the package's `compose.yaml`):

- **A restic rest-server in append-only mode**, with private repositories. The hosting server can add snapshots but cannot delete or overwrite anything. Even someone who fully controls the hosting server cannot throw the copy away, which gives you on your own hardware what Object Lock gives you on [S3](https://www.berthpanel.app/library/backup-to-s3/).
- **TLS only, with a certificate that Berth created.** restic trusts only that certificate and Berth checks its fingerprint, so another machine on the same address is refused. The server signs in with a strong random password, stored on the NAS as a bcrypt hash.
- **A cleanup task** that runs `restic forget --prune` once a day on the NAS itself, with its own repository key and the retention policy from the package. It works directly on the folder with the copy (not through the rest-server, where append-only applies to everyone) and waits while a copy from the server is running. Its key exists only in the package; Berth drops its own copy after connecting.
- **Optionally a Tailscale container** that the rest-server shares its network with, so no port has to be opened on your router.

The retention policy lives only on the NAS on purpose: nothing the server writes decides what the NAS deletes.

## Supported NAS systems

| Brand | Requirement | Where the compose file goes |
|---|---|---|
| Synology | DSM 7.2 with Container Manager | a new project in Container Manager |
| Ugreen | UGOS Pro with the Docker app | a new project in the Docker app |
| TrueNAS | SCALE / Community Edition 24.10 or newer | *Apps → Install via YAML* |

No containers on your NAS, for example TrueNAS CORE? Use the SFTP route described below.

## Setting it up

In the panel: *Backups → Places* → **Add place** → *Your own NAS: Synology, Ugreen or TrueNAS*. The assistant has six steps; it takes about ten minutes.

1. **Brand.** Choose Synology, Ugreen or TrueNAS. The steps and the package differ per brand; the protection is the same everywhere.
2. **Connection.**
   - **Tailscale** (recommended): the package starts its own Tailscale container next to the rest-server. No port opens on the router; this server must be in the same tailnet.
   - **Home network or VPN**: the server reaches the NAS directly. If Tailscale already runs on the NAS itself, enter the NAS's Tailscale address here.
   - **Internet with port forwarding**: the router forwards one port to the NAS. Preferably allow it only for this server's address.

   On TrueNAS you also choose the dataset path. Under *Retention and cleanup on the NAS* you set the policy (default 7 daily, 4 weekly, 6 monthly) and the hour of the daily cleanup, in UTC.
3. **Download the package.** A zip with `compose.yaml`, `LEESMIJ.md` (the steps for your NAS), `NOODHERSTEL.md` (emergency recovery) and `certificaat.pem`. **The package contains keys**: download it once and keep it safe. A new package replaces the previous one once you connect again; until then the existing copy keeps working. With Tailscale you can include an auth key, which only goes into the package.
4. **Put it on the NAS.** Create the folder or dataset, create a project or app, and paste the content of `compose.yaml`. Everything is in that one file; no separate files need to go to the NAS. The page and `LEESMIJ.md` describe the buttons as they are called on your NAS.
5. **Connect and test**. Berth checks that the NAS is reachable, shows the pinned certificate, knows the password and **refuses deletion**: it tries to delete a snapshot that does not exist, and an append-only NAS must refuse. Only when all of that is true does Berth create the encrypted repository, add the cleanup task's key and make the NAS an external place.
6. **First copy and restore test**, in the background. The result arrives as a notification.

Then add or adjust a schedule to the NAS under *Backups → Schedules*.

### From the command line

```bash
berth backup remote nas package --brand synology --connection tailscale -o nas.zip \
  --tailscale-key-file /root/ts-key            # optional: auth key into the package
berth backup remote nas guide --brand synology --connection tailscale   # the steps
berth backup remote nas connect --first-copy   # connect, first copy, restore test
berth backup remote nas                        # status, including cleanup on the NAS
berth backup remote nas test                   # run the full test again
```

Other package options include `--keep-daily`, `--keep-weekly`, `--keep-monthly`, `--prune-hour-utc` and, for TrueNAS, `--dataset`.

## Cleanup on the NAS

Because the server cannot delete anything, it does not prune a NAS. After every round the cleanup task records its result as a small status snapshot. The place's page shows when the NAS last cleaned up and with which policy, and warns (also as a notification after a copy) when cleanup failed or has not succeeded for several days.

To change the policy, edit `KEEP_DAILY`, `KEEP_WEEKLY` and `KEEP_MONTHLY` in `compose.yaml` on the NAS and restart the project.

Before every copy, Berth checks again that the NAS still refuses deletion. If it suddenly allows it (for example after someone replaced the compose file without `--append-only`), the copy continues but you get a warning and a notification.

## A second layer: NAS snapshots

Turn on snapshots for the folder or dataset on the NAS as well:

- Synology: Snapshot Replication;
- TrueNAS: *Data Protection → Periodic Snapshot Tasks*;
- Ugreen: snapshots, if your model offers them for shared folders.

Those snapshots are read-only and outside the cleanup task's reach. If the NAS itself is ever tampered with by someone with administrator rights on it, you roll the folder back to a snapshot from before, restart the project and restore as usual.

## Without containers: SFTP

On a NAS without container support, choose *Without containers (SFTP)* in the assistant, or run `berth backup remote nas sftp`. The page shows per brand how to enable the SFTP service and a user for the backups, and where the server's public key goes (also downloadable as `authorized_keys`). Berth then sets up the copy with a new password that you see once.

```bash
berth backup remote nas sftp --brand truenas --host truenas.example.lan \
  --path /mnt/tank/berth-backup
berth backup remote nas sftp-key   # the server's public key
```

Over SFTP the server **can** delete, and restic cleans up from the server side. With this route, NAS snapshots are not optional.

## Replacing the password

*Replace password* on the place's page, or `berth backup remote rotate`, adds a new key to the repository. On an append-only NAS the old key cannot be removed from the server; the notification gives the command to remove it on the NAS through the cleanup container.

## Restoring from the NAS

Everything you need for an emergency is in the package you downloaded:

- `NOODHERSTEL.md` names the repository address and the password of the copy;
- `certificaat.pem` is the rest-server's certificate; restic refuses the connection without it.

A new server must reach the NAS the same way the old one did: join the same tailnet first, or allow the new server's address on the router.

```bash
umask 077
printf '%s\n' '<password from NOODHERSTEL.md>' > /root/copy-password
berth dr restore --repo 'rest:https://…' --password-file /root/copy-password \
  --cacert certificaat.pem --yes
```

The NAS stays append-only during a restore; Berth only reads. Afterwards it reconnects the NAS as the external place, again without server-side cleanup. See [Disaster recovery](https://www.berthpanel.app/library/disaster-recovery/) for the full procedure.

## Related

- [Restoring files, mail and databases](https://www.berthpanel.app/library/restoring-data/)
- [Restore tests](https://www.berthpanel.app/library/restore-tests/)
- [Backing up to S3](https://www.berthpanel.app/library/backup-to-s3/)
