Update Python n8n instance

One of the things I do a lot lately is update my n8n instance. To help with that, I careated the cheat sheet you see below. I hope that it helps make the process of updating n8n easier!

1. Update Ubuntu Packages (APT)

ONLY RUN THIS WHEN THE CONTAINERS ARE UP AND RUNNING otherwise you might delete important things.
 
# download the lastest packages from the internet
sudo apt update
# install downloaded packages
sudo apt upgrade

2. Free space on the server

ONLY RUN THIS WHEN THE CONTAINERS ARE UP AND RUNNING otherwise you might delete important things.
docker system prune -a
You might want to look into adding more HD space for longer term viability.

3. Make your backup

cd /home/ubuntu/
sudo tar -czf n8n-backup-9-17-2025.tgz n8n/
You might have to cleanup old backups if space is an issue

4. Validate the contents of your backup

tar -ztvf n8n-backup-9-17-2025.tgz

5. Make note of what version you are on incase you need to revert/restore

This is done automatically now on Slack. When n8n boots up, it posts the version it’s on for easy reference.  

6. Update images

Download the latest image of n8n
docker pull n8nio/n8n
# To pull a specific tag, use the following syntax:
docker pull n8nio/n8n:latest  <-- This one
docker pull n8nio/n8n:next
It is however important to remember that you would have to build a new custom image every time a new n8n version gets released.
So would be best to use a Dockerfile like this where the current version is references:
FROM n8nio/n8n
RUN apk add --update python3 py3-pip

7. Remove/Restart containers

Stop the currently running containers
cd n8n
docker-compose stop
Build the newest n8n-python package by referencing the Docker-file above
sudo docker build -t n8n-python .
Remove them so that it has to recreate them and does not reuse the old ones
docker-compose rm
Startup n8n again
docker-compose up -d