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