Files
homeserver/README.md
2026-02-20 21:58:27 +01:00

74 lines
3.0 KiB
Markdown

# Home Server Setup
This is the docker based home server setup for a ubuntu server machine running on proxmos on my N100 mini computer.
The traefik proxy does not run on this machine but it's own LXC container on proxmox, there is a small script to sync it from there to here so I can have it all on one git repo.
Stop home assistant first if jellyfin isn't starting.
Check the wiki here for more information: [wikimd/wiki/homepage.md](wikimd/wiki/homepage.md)
## Drives (view from the ubuntu guest)
| Device | Size | Mount Point | Usage |
|--------|---------|----------------------|---------------------------|
| sda | 1.2TB | `/` (root) | System disk |
| sdb | 4.5TB | `/media/extension` | Media storage (Jellyfin/Samba) |
| sdc | 3.4TB | `/media/ssd` | Additional Samba shares |
## Backup Strategies
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
```