From 00e47f0db521f533ce02e50830cd561ff4eb340a Mon Sep 17 00:00:00 2001 From: Stefan Ostermann Date: Fri, 20 Feb 2026 21:58:27 +0100 Subject: [PATCH] usb drive fix, docs --- README.md | 54 +++++++++++++++++++++++++++++++++++++++++++++++++++++- backup.sh | 49 +++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 102 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 3889ed6..f917b51 100644 --- a/README.md +++ b/README.md @@ -18,4 +18,56 @@ Check the wiki here for more information: [wikimd/wiki/homepage.md](wikimd/wiki/ ## Backup Strategies -TODO +Two scripts handle backups. Both must be run as **root** (`sudo`) because the backup destination is owned by root. + +### File Backup — [`backup.sh`](backup.sh) + +Incremental rsync snapshot backup of `/home/oster/server` to the extension drive. + +- **Destination:** `/media/extension/backup/ubuntu/` +- **Method:** Hard-link incremental snapshots (`--link-dest`) — each daily run creates a new `YYYY-MM-DD/` directory; unchanged files are hard-linked from the previous snapshot, so each snapshot looks complete but only new/changed files consume extra space. +- **Retention:** Configurable at the top of the script: + ```bash + readonly KEEP_DAILY=3 # keep this many daily snapshots + readonly KEEP_WEEKLY=2 # keep this many weekly (Sunday) snapshots + ``` +- **Exclusions:** `.cache`, `node_modules`, `*.tmp`, and DB-related directories (`postgresql`, `mysql`, `db`, `database`) — those are handled separately by `backup-db.sh`. +- **Locking:** A lockfile at `/media/extension/backup/ubuntu/.backup.lock` prevents concurrent runs. Stale locks (from crashed runs) are detected by PID check and removed automatically. + +**Run manually:** +```bash +sudo ./backup.sh +``` + +**Cron example** (daily at 04:00, in root's crontab via `sudo crontab -e`): +``` +0 4 * * * /home/oster/git/homeserver/backup.sh >> /var/log/backup.log 2>&1 +``` + +--- + +### Database Backup — [`backup-db.sh`](backup-db.sh) + +Dumps all PostgreSQL databases from running Docker containers using `pg_dumpall`. + +- **Destination:** `/home/oster/server/backup/` (on the system disk, picked up by `backup.sh` on the next run) +- **Databases backed up:** + + | Container | DB User | Label | + |---|---|---| + | `immich_postgres` | `postgres` | `immich` | + | `authentik-postgresql-1` | `authentik` | `authentik` | + | `paperless-db-1` | `paperless` | `paperless` | + +- **Output format:** `YYYY-MM-DD_HH:MM:SS-