# Immich LXC Setup with External Storage and Backup Strategy

## Overview

<span style="white-space: pre-wrap;">Immich was installed using the </span>**Proxmox Community Scripts**, which resulted in a fully functional LXC container without issues.  
<span style="white-space: pre-wrap;">After the initial setup, the container configuration was adjusted to provide </span>**sufficient storage capacity for photos and videos**, as the default container disk size is not suitable for long-term media storage.

<span style="white-space: pre-wrap;">The solution is based on mapping Immich’s upload directory to a </span>**dedicated large storage volume**<span style="white-space: pre-wrap;"> and handling backups </span>**outside of Proxmox’s standard container backups**.

---

## Storage Layout and Mount Point

### Immich Upload Directory

Immich stores all uploaded media in the following directory inside the container:

```
/opt/immich/upload/
```

<span style="white-space: pre-wrap;">To avoid filling up the container’s root filesystem, this directory is mapped to a </span>**separate mount point**<span style="white-space: pre-wrap;"> backed by a larger disk (e.g. ZFS storage on the Proxmox host).</span>

---

## Mount Point Migration Procedure

### 1. Backup Existing Upload Directory

Before changing anything, log into the Immich LXC and create a backup of the existing upload directory:

```bash
cp -a /opt/immich/upload /opt/immich/upload.backup
```

This ensures the original folder structure and any existing files are preserved.

---

### 2. Create and Map the Mount Point

On the Proxmox host:

- Create a new storage volume (e.g. ZFS dataset or subvolume) with sufficient capacity.
- Map this volume into the LXC at:

```
/opt/immich/upload/
```

This replaces the original directory with the external storage.

---

### 3. Restore Directory Contents

After the mount point is active inside the container:

```bash
cp -a /opt/immich/upload.backup/* /opt/immich/upload/
```

This guarantees that Immich finds the directory structure it expects.

---

### 4. Fix Ownership and Permissions

<span style="white-space: pre-wrap;">Immich requires the upload directory to be owned by the </span>`<span class="editor-theme-code">immich</span>`<span style="white-space: pre-wrap;"> user:</span>

```bash
chown -R immich:immich /opt/immich/upload
```

Failing to do this may lead to upload errors or missing media in the UI.

---

## Backup Considerations (Important)

### ⚠ Proxmox Datacenter Backups

<span style="white-space: pre-wrap;">The mapped mount point </span>**is not included**<span style="white-space: pre-wrap;"> in regular Proxmox container backups.</span>

<span style="white-space: pre-wrap;">This is expected behavior and </span>**must be handled explicitly**.

---

## Backup Strategy

### Restic + rclone (WebDAV)

Backups are handled independently of Proxmox using the following stack:

- **restic**<span style="white-space: pre-wrap;"> for versioned, encrypted backups</span>
- **rclone**<span style="white-space: pre-wrap;"> as the transport layer</span>
- **WebDAV**<span style="white-space: pre-wrap;"> as the remote storage backend as it is the easiest to be used inside LXCs (I think)</span>

This approach provides:

- Encrypted, deduplicated backups
- Independence from container snapshots
- Fine-grained control over retention and scheduling
- Easy restores without Proxmox involvement

Only the external upload storage needs to be backed up; the container itself can be rebuilt at any time.

---

## Design Rationale

- **Large media data is decoupled from the container**
- **Container rebuilds are trivial**
- **Backups are reliable, explicit, and auditable**
- **Storage growth does not require LXC resizing**

This setup aligns well with long-term photo library management and avoids common pitfalls with container-based media applications.