# Restic: Multi-User Syncthing Backup Strategy

# Overview

This document covers the backup of multi-user Syncthing data from the **Syncthing-LXC** (ID: `130`) via the **Vault-LXC**(ID: `150`). We utilize a single unified Restic repository on the NAS to maximize deduplication across common files shared between users.

## Storage Configuration

Individual ZFS subvolumes for each user are passed to the Vault-LXC as **Read-Only** mount points.

<table id="bkmrk-user-host-source-%28zf"><thead><tr><th align="left">User</th><th align="left">Host Source (ZFS)</th><th align="left">Vault-LXC Mount Point</th></tr></thead><tbody><tr><td align="left">**UserA**</td><td align="left">`tank/subvol-130-disk-2`</td><td align="left">`/source/sync-usera`</td></tr><tr><td align="left">**UserB**</td><td align="left">`tank/subvol-130-disk-3`</td><td align="left">`/source/sync-userb`</td></tr><tr><td align="left">**UserC**</td><td align="left">`tank/subvol-130-disk-4`</td><td align="left">`/source/sync-userc`</td></tr></tbody></table>

```bash
# Executed on Proxmox Host to map disks
pct set 150 -mp132 /tank/subvol-130-disk-2,mp=/source/sync-usera,ro=1
pct set 150 -mp133 /tank/subvol-130-disk-3,mp=/source/sync-userb,ro=1
pct set 150 -mp134 /tank/subvol-130-disk-4,mp=/source/sync-userc,ro=1

```

---

## The Unified Backup Script

Using tags allows us to store all users in one repository (`/syncthing`) while being able to filter snapshots by user during recovery.

**`/root/scripts/backup-syncthing.sh` (Vault-LXC):**

```bash
#!/bin/bash

# Auth & Network (Direct 2.5GbE Pipe)
export RESTIC_REPOSITORY="rest:http://vault-user:Pass123@10.1.1.2:8000/syncthing"
export RESTIC_PASSWORD="Sync_Encryption_Key_44"

# Define users and their source directories
declare -A users=(
  ["usera"]="/source/sync-usera"
  ["userb"]="/source/sync-userb"
  ["userc"]="/source/sync-userc"
)

# 1. Individual User Backups (Enables granular recovery)
echo "Starting Syncthing Backups..."

# Loop through users and perform backups
for user in "${!users[@]}"; do
  source_dir="${users[$user]}"
  restic backup "$source_dir" --tag "user:$user" --host "syncthing-srv"
done

# 2. Global Prune (Keep last 7 days for all users)
# Run locally on NAS if server is in --append-only mode
restic forget --keep-within 7d --prune

```

---

## Administration &amp; Recovery

### How to list files for a specific user:

To see only Sarah's backups without cluttering the list with other users:

```bash
restic snapshots --tag "user:sarah"

```

### How to restore a single user's data:

If Werner accidentally deletes a folder, you can restore his latest snapshot specifically:

```bash
restic restore latest --tag "user:werner" --target /tmp/restore-werner

```

## Maintenance Notes

- **Deduplication Advantage:** If Carsten and Sarah both download the same 2GB ISO, Restic only stores the blocks **once** in the NAS repository, saving significant space.
- **Integrity Checks:** Run `restic check` once a month from the Vault-LXC to ensure the NAS data remains uncorrupted.

---

[Restic Guide: Backing Up Multiple PCs](https://www.youtube.com/watch?v=gnqmLUbT7gw)

This video explains how to manage a single repository for multiple sources using tags and hostnames, which is exactly how you are organizing your individual Syncthing users.

<iframe allowfullscreen="allowfullscreen" height="314" src="https://www.youtube.com/embed/gnqmLUbT7gw" width="560"></iframe>