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.
| 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 |
git clone <your-repo-url>
cd immich-auto-updatercp example.env .envOpen .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 timezoneOpen 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|" .envReplace 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).
chmod +x update.sh
./update.shdocker compose up -dImmich will be available at http://your-server-ip:2283.
When you run ./update.sh, it performs these steps in order:
- Backs up current files — copies
docker-compose.yml,hwaccel.ml.yml,hwaccel.transcoding.yml, and.envto*.backupfiles. - Git backup — commits the current working files to the
developbranch and pushes to origin, so you have a history of every version change. - Downloads new files — fetches the official
docker-compose.yml,hwaccel.ml.yml,hwaccel.transcoding.yml, and.envfrom the Immich GitHub release for the target version. - Applies your environment — patches the freshly downloaded
.envwith yourIMMICH_VERSION,DB_PASSWORD, timezone, and any other customsedrules you add. - Patches docker-compose.yml — uncomments the
DB_STORAGE_TYPE: 'HDD'line if present (useful when your database is on an HDD).
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 |
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
}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|" .envIf 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."
}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:
- Check available releases at https://github.com/immich-app/immich/releases
- Open
update.shand change theversionvariable:version="v2.6.0" # set to the desired Immich release tag
- Run the script:
./update.sh
- Verify the new compose files look correct
- Restart Immich:
docker compose down && docker compose up -d
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- Docker and Docker Compose (v2+)
- Git (for version tracking)
- wget (for downloading release files)
- bash 4+ (for associative arrays in the script)
- sed with
-isupport (GNU sed on Linux; on macOS usebrew install gnu-sed)
| 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.