The Privacy Diet code · Part 3 — Your Home Network

Chapter 9 Self-Hosting: Owning Your Stack

4 blocks · pp. 88–90 in the paperback

Tutorials for this chapter: Docker and Compose, Properly Installed , Installing Ubuntu Server for a Home Lab , SSH: Key-Only Login and Sensible Hardening

Installing Docker

# p. 88

Run Terminal, on the server
# On Debian/Ubuntu (recommended base OS for a homelab server):
curl -fsSL https://get.docker.com | sh
# Add your user to the docker group (so you don't need sudo):
sudo usermod -aG docker $USER
# Verify installation:
docker run hello-world

Deploying Vaultwarden (Example)

# p. 88

File docker-compose.yml

In its own folder, e.g. ~/vaultwarden/.

# docker-compose.yml
services:
  vaultwarden:
    image: vaultwarden/server:latest
    container_name: vaultwarden
    restart: unless-stopped
    volumes:
      - ./vw-data:/data
    environment:
      - SIGNUPS_ALLOWED=true   # set to false once your account exists
    ports:
      - 8080:80

Be Your Own Cloud, Chapter 11, has an updated version of this file →

# p. 89

Run Terminal, in the folder with docker-compose.yml
# Start the service:
docker compose up -d
# View logs:
docker compose logs -f
# Update to latest version:
docker compose pull && docker compose up -d

Backups: The Part Everyone Skips

# p. 90

Run Terminal, on the server
# Install restic:
sudo apt install restic
# Initialise a backup repository (example: Backblaze B2):
restic -r b2:your-bucket-name init
# Run a backup:
restic -r b2:your-bucket-name backup /path/to/your/data
Crontab crontab -e
# Schedule with cron (daily at 2am):
0 2 * * * restic -r b2:your-bucket-name backup /path/to/data >> /var/log/restic.log 2>&1

Be Your Own Cloud, Chapter 18, builds this into a full 3-2-1 backup script →

Reproduced exactly from The Privacy Diet, Chapter 9. The book explains what each line does and what to do when it doesn't work. About the book

Something here not working as the book describes? Tell the author.