Update n8n (Docker)

Need to get to the bottom of why this happened before I attempt it again. I have a self-hosted n8n that I’ve been running now for over a year. It’s using postgres and I’ve run into issues updating before (Docker Compose - Data Loss - #2 by shrey-42). I recently attempted to update following the instructions here Updating n8n | Docs. Upon logging in, everything is gone and it’s a blank slate. One thing I did notice was that /root/n8n/postgres-data exists suddenly (/root/n8n is the DATA_FOLDER). Interestingly, when I had this issue before it was because ${DATA_FOLDER}/postgres-data:/var/lib/postgresql/data was missing from the docker-compose.yml. Adding that in and restarting docker restored my data, but /root/n8n/postgres-data didn’t actually exist. I know this because we do full image backups nightly and the folder isn’t there in this morning’s backup. I’m going to just restore the server from the backup this morning, but before I attempt updating again, any thoughts on why this is happening and what I can do to try and troubleshoot the update? Thanks.

Hey @cleveradmin,

Are you running both n8n and Postgres in containers? In my experience when upgrades go wrong and data goes missing it is because the containers are not using persisted volumes on the host and mapping them to the container instead they are just local to the container which gets overwritten when a new image is pulled.

I would start by double checking the container configuration and making sure you have the important data on your host.

Hey @Jon, it get’s stranger and I could really use some guidance here. It would appear that n8n has been running uninterrupted since May when I last had issues. As I mentioned, missing - ${DATA_FOLDER}/postgres-data:/var/lib/postgresql/data in docker-compose.yml was the issue and adding that in got everything back online. At this moment, after restoring from a server image snapshot, everything is working and I’m on 0.144.0. The folder /root/n8n/postgres-data does not exist at this moment. If I run docker-compose down / docker-compose up, the /root/n8n/postgres-data is created and the database initialization script is run, effectively wiping out my database. I’m not even sure how this is possible.

I am not sure on that one either the container shouldn’t remove the folder, can you share your compose file for n8n (removing anything sensitive) and if you have Postgres in docker share the config for that as well.

I don’t think I’m going to bother troubleshooting this, actually. I’ve been looking for an excuse to just move to n8n cloud anyway and this is a good one lol.

2 Likes

That works as a solution as well :joy:

1 Like

And I courious how to backup my n8n on server before proceed to update?

1 Like

Hi @masmoek

If you’re using Docker, As long as you’re using volumes. Your data is safe. I think there is no need of taking backup. Instead, you can backup your workflows if you need.

This is how I update

from the folder where n8n is installed:

docker-compose pull

docker-compose up -d

Hi there!

I did the same as @asirota said right above (adding a step “docker compose down” between the two steps he mentioned)

But when I go back to my instance UI (through my browser) it seems that I’m still under the 0.208.0 version of n8n.

Do you know where to search to troubleshoot?

You can then try to pull the latest image specifically:

docker pull n8nio/n8n:latest
1 Like

Hey Jan!

I just see you answer, it worked as expected!

Lots of thanks!

1 Like

That is great to hear. Have fun!

1 Like