usb drive fix, docs
This commit is contained in:
54
README.md
54
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-<label>.sql.gz` (gzip-compressed SQL dump)
|
||||
- **Retention:** Dumps older than 7 days are automatically deleted.
|
||||
|
||||
**Run manually:**
|
||||
```bash
|
||||
sudo ./backup-db.sh
|
||||
```
|
||||
|
||||
**Cron example** (daily at 03:30, before the file backup):
|
||||
```
|
||||
30 3 * * * /home/oster/git/homeserver/backup-db.sh >> /var/log/backup-db.log 2>&1
|
||||
```
|
||||
|
||||
Reference in New Issue
Block a user