Files
second-brain/projects/homelab/guides/server-maintenance-and-updates.md
T
kiskaadee da0adfc7bf
Brain Structural Validation / Validate Markdown Structure & Links (push) Successful in 6s
docs(projects): standarize homelab taxonomy and convert paths to
relative links

- Update all Homelab documents and engineering journals with core tags
  (`architecture`, `security`, `operations`, `ADR`).
- Replace machine-specific `file:///` URLS and absolute local paths with
  portable relative Markdown links and code backticks.
- Align Homelab project landing page and documentation status with
  current infrastructure topology
2026-09-16 07:25:36 -05:00

3.0 KiB

type, project, tags
type project tags
guide homelab
operations
homelab
nixos
maintenance
systemd
docker

🛠️ Server Maintenance and System Updates Runbook

This runbook outlines routine maintenance procedures for the Homelab Core appliance, including NixOS system upgrades, service health verification, garbage collection, and Docker pruning.


🔄 Updating the NixOS Server Appliance

The server operating system is defined entirely inside ~/Core.

Step 1: Update Flake Inputs

To fetch the latest versions of Nixpkgs and sops-nix:

cd ~/Core
nix flake update

Step 2: Validate the Build Dryly

Always dry-build before switching to catch compilation, syntax, or package evaluation errors:

nix flake check
nix build .#nixosConfigurations.server.config.system.build.toplevel --no-link

Step 3: Switch to the New System Generation

Once the dry build completes cleanly:

sudo nixos-rebuild switch --flake ~/Core#server
# (or simply run: nix-switch)

🏥 Post-Update Health Checklist

Run this quick verification checklist following any system switch or server reboot:

  1. Systemd Daemon Health: Ensure no core background units failed:

    systemctl --failed
    
  2. Core Homelab Stack: Verify Traefik, Authelia, and the control plane containers are active:

    systemctl status homeserver-core.service
    
  3. Dynamic DNS (Dynu) Monitor: Ensure the IP change detector timer and service are active:

    systemctl status dynu-monitor.timer
    systemctl status dynu-monitor.service
    
  4. GitOps Webhook Dispatcher: Verify the webhook listener is listening on port 9000:

    systemctl status homelab-gitops.service
    
  5. Secrets Integrity: Verify rendered environment files were generated in RAM:

    sudo ls -la /run/secrets/rendered/
    
  6. Application Workload Status: Inspect the status of all application stacks:

    appctl list
    

🧹 Disk Space Reclamation & Garbage Collection

Over time, older Nix generations, build artifacts, and Docker layers accumulate on disk. Follow this clean-up routine:

1. Collect Nix Garbage

To prune unreachable store paths and older generations:

# Delete older system generations (older than 7 days)
sudo nix-env --delete-generations +7d --profile /nix/var/nix/profiles/system

# Prune the store
sudo nix-collect-garbage -d

2. Prune Unused Docker Resources

Remove dangling container images, stopped containers, and build cache:

# Prune dangling images and build cache safely
docker system prune -a --volumes --filter "until=168h"

(Only prunes containers stopped for longer than 7 days).


🚨 Emergency System Rollback

If a newly applied NixOS generation causes system issues:

# Roll back to the previous generation immediately
sudo nixos-rebuild switch --rollback

(Or select the previous generation from the systemd-boot menu upon reboot).