From 2db05c9bb680ef964cdb04a1bfc11c7e67f33404 Mon Sep 17 00:00:00 2001 From: Christoph Haas Date: Sat, 19 Sep 2026 20:36:47 +0000 Subject: [PATCH] Add setup.sh with nightly systemd timer; move key and excludes into /opt/backup --- .gitignore | 3 +- README.backup.md | 26 ++++++++--- backup.env.sample | 2 +- backup.sh | 24 +++------- exclude | 10 ++++ setup.sh | 113 ++++++++++++++++++++++++++++++++++++++++++++++ 6 files changed, 151 insertions(+), 27 deletions(-) create mode 100644 exclude create mode 100755 setup.sh diff --git a/.gitignore b/.gitignore index f3532a1..86d713d 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,3 @@ -# Secrets — never commit the real env file +# Secrets — never commit backup.env +encryption-key.pem diff --git a/README.backup.md b/README.backup.md index 9038144..eff15b4 100644 --- a/README.backup.md +++ b/README.backup.md @@ -13,23 +13,35 @@ Everything lives in `/opt/backup/`. The connection details and credentials |------|---------| | `backup.env` | Shared config: server, datastore, namespace, token, key (sourced by both scripts) | | `backup.env.sample` | Template — copy to `backup.env` and fill in real values | +| `setup.sh` | Install the client and create the encryption key (run once as root) | | `backup.sh` | Full backup of `/` with client-side encryption | | `restore.sh` | FUSE-mount the encrypted backup to browse/restore files | -| `/etc/proxmox-backup/encryption-key.pem` | Client-side encryption key (store a copy off-host!) | -| `/etc/proxmox-backup/defaults.exclude` | Paths excluded from the backup | +| `/opt/backup/encryption-key.pem` | Client-side encryption key (store a copy off-host!) | +| `/opt/backup/exclude` | Paths excluded from the backup | + +## Setup + +On a fresh host, as root: + +``` +./setup.sh +cp backup.env.sample backup.env +$EDITOR backup.env # fill in server, datastore, namespace, token +chmod 600 backup.env +``` ## How `backup.sh` works 1. Sources `backup.env`, which exports the connection/auth settings (server, datastore, port, API token) as separate `PBS_*` component variables. This matters: `PBS_AUTH_ID` is only honoured when `PBS_REPOSITORY` is *not* set. -2. Builds `--exclude` flags from `/etc/proxmox-backup/defaults.exclude` +2. Builds `--exclude` flags from `/opt/backup/exclude` (`/proc`, `/sys`, `/dev`, `/run`, `/tmp`, …). 3. Runs: ``` proxmox-backup-client backup "${HOSTNAME}-root.pxar:/" \ - --keyfile /etc/proxmox-backup/encryption-key.pem \ + --keyfile /opt/backup/encryption-key.pem \ --ns "$BACKUP_NS" \ --exclude /proc/* ... ``` @@ -46,8 +58,8 @@ The **encryption key is the only thing that makes the backups readable**. If this host and the key are both lost, the backup is unrecoverable — no one at the PBS provider can help. -- File: `/etc/proxmox-backup/encryption-key.pem` -- Fingerprint: `proxmox-backup-client key show /etc/proxmox-backup/encryption-key.pem` +- File: `/opt/backup/encryption-key.pem` +- Fingerprint: `proxmox-backup-client key show /opt/backup/encryption-key.pem` Keep a copy somewhere safe that is **not this machine**: - offline USB stick / printed paperkey @@ -138,7 +150,7 @@ First source the shared config (`source /opt/backup/backup.env`), then: ``` proxmox-backup-client restore host//