feat: extract deployment config into configs/ for multi-server reuse

Both borg-backup.sh and restore.sh now source a config file instead of
hardcoding paths and container names. Default is backup.conf next to the
script; override with BACKUP_CONF=/path/to/other.conf.

- configs/srv.conf     — current server (unchanged behaviour)
- configs/nexusvoice.conf — nexusvoice server (/home/acid/nexusvoice,
                            separate Scaleway path par-backup-1/nexusvoice)
- DB steps in borg-backup.sh are now guarded on [[ -n "$DB_CONTAINER" ]]
  so a config with DB_CONTAINER="" skips the dump entirely
- RUNBOOK.md §2 documents single and multi-deployment patterns

Co-Authored-By: Claude Sonnet 4.6 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01A3rQSEidP6Y61kaCtxjVV1
This commit is contained in:
2026-08-30 23:45:10 +01:00
co-authored by Claude Sonnet 4.6
parent bfafb09ee6
commit 74390b78af
5 changed files with 161 additions and 65 deletions
+26 -4
View File
@@ -50,21 +50,43 @@ Run once, by hand, on the server:
## 2. Deploying the Scripts
Copy `borg-backup.sh`, `dump_db.sh`, and `restore.sh` to `/opt/backup-agent/`
(this exact path is what `borg-backup.sh` invokes for `dump_db.sh`). Make
all three executable:
### Single deployment (default)
Copy `borg-backup.sh`, `dump_db.sh`, `restore.sh`, and your chosen config
from `configs/` to `/opt/backup-agent/`. Symlink the config as `backup.conf`
next to the scripts, or set `BACKUP_CONF` in the cron entry:
```bash
chmod +x /opt/backup-agent/borg-backup.sh /opt/backup-agent/restore.sh
chmod +x /opt/backup-agent/dump_db.sh
# Option A — symlink (scripts auto-discover backup.conf beside them):
ln -s /opt/backup-agent/configs/srv.conf /opt/backup-agent/backup.conf
# Option B — explicit env var in the cron entry (see §3).
```
### Multiple deployments on different servers
Each server gets its own config file. Deploy the same three scripts to
`/opt/backup-agent/` on each server. Point each server's cron entry at its
config via `BACKUP_CONF`:
```
# /etc/cron.d/borg-backup (nexusvoice server)
BACKUP_CONF=/opt/backup-agent/configs/nexusvoice.conf
30 2 * * * root /opt/backup-agent/borg-backup.sh >> /var/log/borg/cron.log 2>&1
```
Before running, verify/update `configs/nexusvoice.conf`:
- `TARGET` — confirm `/home/acid/nexusvoice` (or `/opt/nexusvoice` after the move)
- `DB_CONTAINER` — confirm the MariaDB container name on that server
- `REPO` — must not overlap with the srv repo; uses separate Scaleway path
## 3. Scheduling
Add a cron entry to run the backup daily, off-peak:
```
# /etc/cron.d/borg-backup
# /etc/cron.d/borg-backup (srv — default config via symlink)
30 2 * * * root /opt/backup-agent/borg-backup.sh >> /var/log/borg/cron.log 2>&1
```