Immich Self-Hosted Photo Backup on Linux with External Storage
Platform

Immich Self-Hosted Photo Backup on Linux with External Storage

  • AuthorLiam K.
  • Date
  • Time18 minutes

Immich is a high-performance self-hosted photo and video platform with mobile apps, facial recognition, and timeline browsing. Storage planning matters more than the install itself: original assets grow fast, and machine-learning containers need RAM. This guide gets Immich running with HTTPS and a sane backup layout.

Prerequisites

  • Linux server with 4+ CPU and 8 GB RAM (ML features need more)
  • Fast disk or dedicated volume for uploads and thumbnails
  • DNS for photos.example.com

Step 1: Prepare Storage Layout

bash
sudo mkdir -p /mnt/photos/{library,postgres,model-cache,encoded-video}
sudo mkdir -p /opt/immich
cd /opt/immich
# Prefer a separate disk mounted at /mnt/photos for originals and DB.

Step 2: Download Official Compose Files

bash
wget -O docker-compose.yml https://github.com/immich-app/immich/releases/latest/download/docker-compose.yml
wget -O .env https://github.com/immich-app/immich/releases/latest/download/example.env
sed -i 's|^UPLOAD_LOCATION=.*|UPLOAD_LOCATION=/mnt/photos/library|' .env
sed -i 's|^DB_DATA_LOCATION=.*|DB_DATA_LOCATION=/mnt/photos/postgres|' .env
# Set DB_PASSWORD to a strong random value
DB_PASSWORD=$(openssl rand -hex 24)
sed -i "s|^DB_PASSWORD=.*|DB_PASSWORD=$DB_PASSWORD|" .env
chmod 600 .env
docker compose up -d
docker compose ps

Step 3: Reverse Proxy with Large Uploads

bash
sudo tee /etc/nginx/sites-available/immich >/dev/null <<'EOF'
server {
    listen 80;
    server_name photos.example.com;
    client_max_body_size 0;

    location / {
        proxy_pass http://127.0.0.1:2283;
        proxy_http_version 1.1;
        proxy_set_header Host $host;
        proxy_set_header X-Real-IP $remote_addr;
        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
        proxy_set_header X-Forwarded-Proto $scheme;
        proxy_set_header Upgrade $http_upgrade;
        proxy_set_header Connection "upgrade";
        proxy_buffering off;
        proxy_request_buffering off;
        proxy_read_timeout 600s;
    }
}
EOF
sudo ln -sf /etc/nginx/sites-available/immich /etc/nginx/sites-enabled/immich
sudo nginx -t && sudo systemctl reload nginx
sudo certbot --nginx -d photos.example.com --redirect

Step 4: Create Admin and Connect Mobile Apps

Open https://photos.example.com, create the admin user, then point the Immich mobile app at the same URL. Enable background backup on Wi-Fi only if cellular data is limited.

Step 5: External Library and Backup

bash
# External libraries can mount existing NAS folders read-only into Immich
# Backup originals + DB regularly
tar -czf /var/backups/immich-library-$(date +%F).tar.gz -C /mnt/photos library
docker compose exec -T database pg_dumpall -U postgres | gzip > /var/backups/immich-db-$(date +%F).sql.gz

Production Checklist

  • Keep originals on a monitored volume with free-space alerts.
  • Back up the database and upload library together.
  • Pin Immich release versions; ML model upgrades can be heavy.
  • Restrict registration after the first family/team accounts exist.
  • Disable public sharing links if the instance should stay private.

"Photo platforms look like apps, but in production they are storage systems with an authentication UI."

Technical Author

Liam K.

Liam K.

Founder of Trivox. Writes about how the platform, the network, and the Amsterdam sites fit together.