Two bash scripts to safely keep Ollama up to date on Ubuntu/Linux systems while preserving your custom service configurations.
| Script | Purpose |
|---|---|
upgrade_ollama.sh |
Performs the actual upgrade (backup → stop → install → restore → start). |
check_ollama_update.sh |
Checks whether a newer version is available and optionally triggers the upgrade automatically. |
upgrade_ollama.sh automates the process of upgrading Ollama while ensuring that your custom systemd service configuration is maintained.
check_ollama_update.sh queries the GitHub Releases API, compares the latest tag against the locally installed version, and can either report that an update is available (useful in cron / CI) or immediately invoke upgrade_ollama.sh when --auto-upgrade is passed.
Both scripts provide colorful, emoji-enhanced output to clearly show the progress of each step.
- 🛡️ Preserves your custom Ollama service configuration
- 🎨 Colorful, informative output with emojis
- 🔄 Seamless upgrade process with minimal downtime
- ✅ Verification steps to confirm successful installation
- 🚨 Error checking for critical operations
- 🤖 Automated version checking with configurable auto-upgrade
- 🔕 Silent mode for cron-friendly operation
- Ubuntu/Linux system with Ollama installed
systemdfor service managementcurl(for the update check and upgrade install)- Sudo privileges
-
Clone this repository:
git clone https://github.com/phreck/ollama_ubuntu_upgrade.git cd ollama_ubuntu_upgrade -
Make the scripts executable:
chmod +x upgrade_ollama.sh check_ollama_update.sh
-
Run the upgrade script with sudo:
sudo ./upgrade_ollama.sh
# Check whether an update is available (exits 0 = up to date, 1 = update available, 2 = error)
./check_ollama_update.sh
# Check and automatically upgrade if a newer version is found
sudo ./check_ollama_update.sh --auto-upgrade
# Same as above but with no output (for cron jobs)
sudo ./check_ollama_update.sh --auto-upgrade --silentTo check for updates every night at 2 AM and upgrade automatically, add this line with sudo crontab -e:
0 2 * * * /path/to/ollama_ubuntu_upgrade/check_ollama_update.sh --auto-upgrade --silent >> /var/log/ollama_update.log 2>&1Replace /path/to/ollama_ubuntu_upgrade with the actual path where the repository is cloned.
| Code | Meaning |
|---|---|
0 |
Ollama is already up to date (or was just successfully upgraded). |
1 |
A newer version is available (--auto-upgrade was not passed). |
2 |
A runtime error occurred (Ollama not installed, network failure, etc.). |
- Displays the currently installed Ollama version
- Backs up your custom service configuration (if it exists)
- Stops the running Ollama service
- Downloads and installs the latest version of Ollama
- Restores your custom service configuration and re-enables the service if it was enabled
- Reloads systemd and restarts Ollama
- Verifies the installation by printing the new Ollama version
- Confirms Ollama is installed and reads the current version
- Fetches the latest release tag from the GitHub API
- Compares the two versions
- Reports whether an update is available
- If
--auto-upgradeis passed and an update exists, delegates toupgrade_ollama.sh
- This script is intended for systems where you have customized the Ollama systemd service
- Always ensure you have a backup of your important data before performing any system upgrades
- If you encounter any issues, please create an issue in this repository
MIT License - feel free to modify and distribute as needed.
Contributions are welcome! Please feel free to submit a Pull Request.
If you have any questions or suggestions, please open an issue or contact [email protected].
Last updated: April 17, 2026