> ## Content Index
> Fetch the complete content index at: https://logbuch-homelab.nichedthemes.com/llms.txt
> Use this file to discover other available public pages before exploring further.

# Nightly restic backups to the NAS
- URL: https://logbuch-homelab.nichedthemes.com/nightly-restic-backups-to-the-nas/
- Published: 2026-07-12T08:00:00.000Z
- Updated: 2026-07-12T08:00:00.000Z
- Description: Every node runs restic at 04:00 into one repository on the NAS. A systemd timer starts it, and only the NAS prunes.
- Author: Tomasz Wieland
- Tags: Homelab, Proxmox, Rebuilding the rack, Backups, #Import 2026-11-19 07:37

Proxmox’s weekly dumps restore a whole guest. Most of the time I need one file from yesterday, so every node now runs restic 0.17.3 at 04:00 into one repository on the NAS, at `/srv/restic`. restic deduplicates across the three nodes and encrypts everything before it leaves them.

## A user and a repository

restic reaches the NAS over SFTP as a user that owns the repository and nothing else. On the NAS:

```console
$ sudo useradd --create-home --shell /bin/sh restic
$ sudo install -d -o restic -m 700 /srv/restic
```

Then once, from pve-1:

```console
$ restic -r sftp:restic@nas:/srv/restic init
enter password for new repository:
enter password again:
created restic repository 1c9f02ab7e at sftp:restic@nas:/srv/restic
```

The password goes into `/root/.restic-password` on each node, mode 600, and into the password manager. Without it the repository is noise.

## The script

```bash
#!/usr/bin/env bash
set -euo pipefail

export RESTIC_REPOSITORY=sftp:restic@nas:/srv/restic
export RESTIC_PASSWORD_FILE=/root/.restic-password

restic backup --one-file-system --exclude-caches \
  --tag nightly /etc /root /var/lib/vz
```

`--one-file-system` keeps it out of `/mnt/pve`, where the share with the weekly dumps is mounted. Backing up the backups once was enough.

## The timer

```ini
[Unit]
Description=restic backup to the NAS
OnFailure=mail-root@%n.service

[Service]
Type=oneshot
ExecStart=/usr/local/bin/backup.sh
IOSchedulingClass=idle
```

```ini
[Unit]
Description=Nightly restic backup

[Timer]
OnCalendar=*-*-* 04:00:00
Persistent=true

[Install]
WantedBy=timers.target
```

`Persistent=true` catches up on a run missed while the node was off. `OnFailure=` starts a unit that mails the service’s status to root, and root’s mail goes to the address in `/etc/aliases`.

```console
$ sudo systemctl enable --now restic-backup.timer
```

## Pruning on the NAS

Three nodes pruning one repository would fight over its lock, so only the NAS forgets old snapshots, on Sundays at 06:00, when the nodes are long done.

```console
$ restic -r /srv/restic forget --keep-daily 7 --keep-weekly 4 --keep-monthly 6 --prune
```

## The first restore

A backup counts once a restore has worked. This one brought back yesterday’s `/etc/hosts` of pve-2, and `diff` found nothing to say:

```console
$ restic -r sftp:restic@nas:/srv/restic restore latest --host pve-2 --include /etc/hosts --target /tmp/restore
$ diff /etc/hosts /tmp/restore/etc/hosts
```

The next chapter puts all four chapters into one Ansible repository.