Running your own Immich server is awesome, but keeping it updated can be a tiny hassle. Hereās a simple Bash script that checks your current version, compares it with the latest GitHub release, and even helps you update safely.
How it Works:
- Check Current Version ā Pulls your running Immich version via API.
- Check Latest Release ā Fetches the latest release from GitHub.
- Compare Versions ā Detects major, minor, or patch updates.
- Update Easily ā Prompts you to update, then pulls the new Docker image and restarts the server.
How to find api token?
go to settings > API keys > New API key [only server permission is required]
š” Community tip: You can even run this on a cron job to get regular reminders about updates.
#!/bin/bash
set -e
# -------------------------------
# Configuration
# -------------------------------
IMMICH_PORT=xxxxx
IMMICH_API_KEY="xxxxx"
# -------------------------------
# Function to get current Immich version
# -------------------------------
get_current_version() {
RESPONSE=$(curl -s -H "x-immich-api-key: $IMMICH_API_KEY" \
http://localhost:$IMMICH_PORT/api/server/version)
# Extract version from major.minor.patch
VERSION=$(echo "$RESPONSE" | sed -n 's/.*"major":\([0-9]*\).*"minor":\([0-9]*\).*"patch":\([0-9]*\).*/\1.\2.\3/p')
if [[ -z "$VERSION" ]]; then
VERSION="unknown"
fi
echo "$VERSION" # NO 'v' prefix here
}
# -------------------------------
# Function to get latest release from GitHub
# -------------------------------
get_latest_version() {
TAG=$(curl -s https://api.github.com/repos/immich-app/immich/releases/latest \
| sed -n 's/.*"tag_name": *"\([^"]*\)".*/\1/p')
# Strip leading 'v' if present
echo "${TAG#v}"
}
# -------------------------------
# Compare versions
# -------------------------------
compare_versions() {
IFS='.' read -r c_major c_minor c_patch <<< "$1"
IFS='.' read -r l_major l_minor l_patch <<< "$2"
if [[ "$c_major" -lt "$l_major" ]]; then
echo "major"
elif [[ "$c_minor" -lt "$l_minor" ]]; then
echo "minor"
elif [[ "$c_patch" -lt "$l_patch" ]]; then
echo "patch"
else
echo "none"
fi
}
# -------------------------------
# Main script
# -------------------------------
echo "š Checking Immich versions..."
CURRENT_VERSION=$(get_current_version)
LATEST_VERSION=$(get_latest_version)
if [[ -z "$LATEST_VERSION" ]]; then
LATEST_VERSION="unknown"
fi
echo "ā”ļø Current running version: v$CURRENT_VERSION"
echo "ā”ļø Latest available version: v$LATEST_VERSION"
if [[ "$CURRENT_VERSION" == "$LATEST_VERSION" ]] || [[ "$LATEST_VERSION" == "unknown" ]]; then
echo "ā
No update required. You are running the latest version."
exit 0
fi
UPDATE_TYPE=$(compare_versions "$CURRENT_VERSION" "$LATEST_VERSION")
case $UPDATE_TYPE in
major)
echo "ā ļø Major update available!"
;;
minor)
echo "ā¹ļø Minor update available."
;;
patch)
echo "š§ Patch update available."
;;
esac
read -p "Do you want to update Immich to v$LATEST_VERSION? (y/n): " confirm
if [[ "$confirm" =~ ^[Yy]$ ]]; then
echo "š Updating Immich..."
docker compose down
docker compose pull
docker compose up -d
echo "ā
Immich update complete."
else
echo "ā Update cancelled."
fi