# Building a Self-Hosted Photo Library That Survives Real Life

Most self-hosted photo setups start with good intentions and end with a folder full of half-imported phone backups. The hard part is not storing JPEGs; it is making imports boring, search usable, and backups predictable. For my own library, I wanted something that could ingest photos from multiple phones, preserve originals, generate fast previews, and keep working without a cloud subscription.

## Storage Layout

The simplest reliable pattern has been keeping originals immutable and letting the photo app maintain its own database and thumbnails separately. I store originals on a ZFS dataset mounted read-write only for the import service, then expose them read-only to the gallery container. That separation makes it much harder for an application bug, bad sync client, or mistaken cleanup job to damage the archive.

## Container Setup

A minimal container configuration is enough if the storage paths are clear and backups are planned from the start:

```yaml
services:
  photos:
    image: ghcr.io/immich-app/immich-server:release
    volumes:
      - /srv/photos/originals:/usr/src/app/upload
      - /srv/photos/cache:/usr/src/app/cache
    environment:
      TZ: America/Toronto
```

## Imports and Metadata

Phone uploads go into a staging area first, where duplicate detection and EXIF checks run before files enter the main library. I avoid renaming files based only on timestamps because burst shots, edited copies, and screenshots can collide. A safer structure is `YYYY/MM/DD/original-filename`, with the database providing albums, faces, locations, and search instead of encoding all meaning into paths.

## Backups

The backup strategy is intentionally boring: nightly filesystem snapshots, weekly replication to another machine, and a monthly encrypted copy stored off-site. The database is backed up alongside the originals, but the originals remain the source of truth. I test restores by rebuilding the app from the photo directory and database dump on a spare host, because an untested backup is just optimism with a timestamp.

## Final Notes

Self-hosting photos is worth it when the system becomes quieter than the alternatives. The best setup is not the one with the most features; it is the one that imports automatically, preserves originals, restores cleanly, and does not require constant attention every time a phone fills up.