Add failure logging/email notification in backup.sh; harden /opt/backup perms
This commit is contained in:
parent
d06a9eac7d
commit
68aae4715d
5 changed files with 57 additions and 5 deletions
|
|
@ -11,13 +11,14 @@ Everything lives in `/opt/backup/`. The connection details and credentials
|
|||
|
||||
| File | Purpose |
|
||||
|------|---------|
|
||||
| `backup.env` | Shared config: server, datastore, namespace, token, key (sourced by both scripts) |
|
||||
| `backup.env` | Shared config: server, datastore, namespace, token, key, `NOTIFY_EMAIL` (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 |
|
||||
| `/opt/backup/encryption-key.pem` | Client-side encryption key (store a copy off-host!) |
|
||||
| `/opt/backup/exclude` | Paths excluded from the backup |
|
||||
| `backup.log` | Runtime log written by `backup.sh` (created on each run) |
|
||||
|
||||
## Setup
|
||||
|
||||
|
|
@ -53,6 +54,31 @@ chmod 600 backup.env
|
|||
4. The client encrypts everything locally before uploading. The PBS only ever
|
||||
stores ciphertext and cannot read the data.
|
||||
|
||||
The client's output is piped through `tee` into `backup.log` (the file in the
|
||||
table above). The script captures the client's exit status (via
|
||||
`set -o pipefail`), so a failed `proxmox-backup-client` run is detected even
|
||||
though its output went through `tee`.
|
||||
|
||||
## Failure notification
|
||||
|
||||
If `backup.sh` fails it exits non-zero and, when a mailbox is configured, emails
|
||||
the failure. Set it in `backup.env`:
|
||||
|
||||
```
|
||||
NOTIFY_EMAIL="admin@example.com"
|
||||
```
|
||||
|
||||
Empty (the default) disables mail. There is no `mail`/`mailx` on the hosts, so
|
||||
the script sends via Postfix directly with:
|
||||
|
||||
```
|
||||
... | sendmail -t
|
||||
```
|
||||
|
||||
The mail body contains the timestamp and the contents of `backup.log`. This only
|
||||
covers `backup.sh` failures — a *missed* run (host down, cron removed) is not
|
||||
detected, so monitor the PBS side too.
|
||||
|
||||
Encryption is client-side. The key file has no password (`kdf: none`), so
|
||||
**possession of the key file alone is enough to decrypt** — protect it.
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue