Skip to content

About

Automated Immich Docker updater — downloads official release files, applies your custom environment, and version-tracks every upgrade via Git.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Latest commit

 

History

1 Commit

Folders and files

Repository files navigation

Immich Auto-Updater

A script that automates updating your self-hosted Immich instance by downloading the latest official Docker Compose files, applying your custom environment settings, and committing the changes to Git — all in one command.

Files

File Purpose
update.sh Main update script — run this to update Immich
docker-compose.yml Docker Compose definition for all Immich services
example.env Template environment file — copy this to .env and customise
hwaccel.ml.yml Hardware acceleration options for machine learning
hwaccel.transcoding.yml Hardware acceleration options for video transcoding

Quick Start

1. Clone the repository

git clone <your-repo-url>
cd immich-auto-updater

2. Create your .env file

cp example.env .env

3. Edit .env with your settings

Open .env in your editor and set your values:

UPLOAD_LOCATION=./library          # Where Immich stores uploaded photos
DB_DATA_LOCATION=./postgres        # Where PostgreSQL stores its data
IMMICH_VERSION=release             # "release" for latest, or pin e.g. "v2.5.6"
DB_PASSWORD=change-me-to-something-random   # Use A-Za-z0-9 only
TZ=America/New_York                # Your timezone

4. Configure update.sh with your credentials

Open update.sh and replace the two placeholder values inside the update_env() function:

# Line 54 — set your database password
sed -i "s/^DB_PASSWORD=.*/DB_PASSWORD=YOUR_DB_PASSWORD_HERE/" .env

# Line 57 — set your timezone
sed -i "s|^TZ=.*|TZ=YOUR_TIMEZONE_HERE|" .env

Replace YOUR_DB_PASSWORD_HERE with the same strong password you set in .env, and YOUR_TIMEZONE_HERE with your TZ identifier (e.g. Asia/Kolkata, Europe/London, America/Chicago).

5. Run the update

chmod +x update.sh
./update.sh

6. Start Immich

docker compose up -d

Immich will be available at http://your-server-ip:2283.


What update.sh Does (Step by Step)

When you run ./update.sh, it performs these steps in order:

  1. Backs up current files — copies docker-compose.yml, hwaccel.ml.yml, hwaccel.transcoding.yml, and .env to *.backup files.
  2. Git backup — commits the current working files to the develop branch and pushes to origin, so you have a history of every version change.
  3. Downloads new files — fetches the official docker-compose.yml, hwaccel.ml.yml, hwaccel.transcoding.yml, and .env from the Immich GitHub release for the target version.
  4. Applies your environment — patches the freshly downloaded .env with your IMMICH_VERSION, DB_PASSWORD, timezone, and any other custom sed rules you add.
  5. Patches docker-compose.yml — uncomments the DB_STORAGE_TYPE: 'HDD' line if present (useful when your database is on an HDD).

How Custom Environment Settings Work

Every time update.sh runs, it downloads a fresh .env from the Immich release. Your personal settings would be lost — so the update_env() function re-applies them automatically using sed.

The default update_env() function handles three settings:

Setting What it does
IMMICH_VERSION Pins the version to the one set in the version variable at the top of the script
DB_PASSWORD Sets your database password
TZ Uncomments and sets your timezone

Adding a new custom setting

To persist any additional .env variable across updates, add a new sed line inside update_env().

Example — change the upload location:

update_env() {
    echo "Updating .env file"
    sed -i "s/^IMMICH_VERSION=.*/IMMICH_VERSION=${version}/" .env
    sed -i "s/^DB_PASSWORD=.*/DB_PASSWORD=MyStr0ngPassw0rd/" .env
    sed -i '/^# *TZ=/s/^# *//' .env
    sed -i "s|^TZ=.*|TZ=Europe/London|" .env

    # Custom: change the upload location
    sed -i "s|^UPLOAD_LOCATION=.*|UPLOAD_LOCATION=/mnt/photos/immich|" .env

    # Custom: change the database location
    sed -i "s|^DB_DATA_LOCATION=.*|DB_DATA_LOCATION=/mnt/data/postgres|" .env
}

Removing a setting

Simply delete or comment out the corresponding sed line. For example, to stop overriding the timezone, remove these two lines:

    # Delete or comment out:
    # sed -i '/^# *TZ=/s/^# *//' .env
    # sed -i "s|^TZ=.*|TZ=Europe/London|" .env

Adding a docker-compose.yml patch

If you need to patch docker-compose.yml after every download (e.g. uncomment hardware acceleration), add a function similar to uncomment_db_storage_type().

Example — enable NVENC transcoding:

enable_hw_transcoding() {
    echo "Enabling NVENC hardware transcoding"
    # Uncomment the extends block for transcoding
    sed -i 's|^    # extends:$|    extends:|' docker-compose.yml
    sed -i 's|^    #   file: hwaccel.transcoding.yml|      file: hwaccel.transcoding.yml|' docker-compose.yml
    sed -i 's|^    #   service: cpu .*|      service: nvenc|' docker-compose.yml
}

Then call it from main():

main() {
    backup_files
    git_backup
    download_files
    update_env
    uncomment_db_storage_type
    enable_hw_transcoding      # <-- add here
    echo "Done downloading and updating. Kindly verify the new files."
}

Updating to a New Immich Version

In update.sh, the version is controlled by a single variable at the top of the file:

# Configurable Variables
# To upgrade Immich, change the version below to the desired release tag
# from https://github.com/immich-app/immich/releases and run: ./update.sh
version="v2.5.6"

Steps:

  1. Check available releases at https://github.com/immich-app/immich/releases
  2. Open update.sh and change the version variable:
    version="v2.6.0"   # set to the desired Immich release tag
  3. Run the script:
    ./update.sh
  4. Verify the new compose files look correct
  5. Restart Immich:
    docker compose down && docker compose up -d

Git Version History

The script automatically commits your current files to the develop branch before downloading new ones. Each commit message shows the version transition:

v2.5.6 (was v2.5.5)

This gives you a full history of every update. To roll back:

git log --oneline            # find the commit to roll back to
git checkout <commit-hash> -- .env docker-compose.yml hwaccel.ml.yml hwaccel.transcoding.yml
docker compose down && docker compose up -d

Prerequisites

  • Docker and Docker Compose (v2+)
  • Git (for version tracking)
  • wget (for downloading release files)
  • bash 4+ (for associative arrays in the script)
  • sed with -i support (GNU sed on Linux; on macOS use brew install gnu-sed)

Full .env Reference

Variable Default Description
UPLOAD_LOCATION ./library Path where uploaded photos/videos are stored
DB_DATA_LOCATION ./postgres Path where PostgreSQL data is stored
IMMICH_VERSION release Immich version tag (release for latest)
DB_PASSWORD postgres PostgreSQL password (change this!)
DB_USERNAME postgres PostgreSQL username
DB_DATABASE_NAME immich PostgreSQL database name
TZ (commented) Server timezone (TZ list)

For all supported environment variables, see the Immich docs.

About

Automated Immich Docker updater — downloads official release files, applies your custom environment, and version-tracks every upgrade via Git.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Used by

Contributors

Languages