N8n selfhosted docker update, lost data

Installed using the docker instructions, I did create the volume per the instructions.

Just followed the docker-compose update instructions and it’s asking me for my information again, as if I have never used it.

I’m hoping there’s a way to attach the volume and get my workflows back.
Currently the docker compose has this for the n8n volume:

volumes:
      - n8n_data:/home/username/n8n/n8n-local-files:/files

If I can change this line to get my workflows back, I created the volume while in /home/username/n8n/ what should the line look like to get them back?

Very new to docker… hoping i didn’t wipe them out by following the documented update procedure.

This is the doc i followed to install.

Will data persist between updates using this method?

Hi @tkintenn, I am very sorry you are having trouble.

From which version did you upgrade? Is there a chance you upgraded from an n8n version before v1 and have missed this step?

If I can change this line to get my workflows back, I created the volume while in /home/username/n8n/ what should the line look like to get them back?

So the line in itself looks problematic to me. The syntax of the volumes section in a docker compose would be this:

volumes:
  - {path or volume on your host machine}:{path inside your docker container}

So the host path (or docker volume) on the left side of the : and the path inside the n8n docker container on the right side. You do however seem to have a line with three values.

My best guess is these were originally two separate lines, something like this:

volumes:
  - n8n_data:/home/node/.n8n
  - n8n-local-files:/files

Now assuming you have used /home/node/.n8n as the part on the right hand side (which is where the standard n8n docker image would write data to) and you were already using n8n v1 or later, the above should bring back your data.

Keep in mind this is just my best guess made without knowing exactly how you previously deployed and configured n8n.

Hope this still helps :crossed_fingers:

I rebuilt my flows. But now I see I’m a few updates behind. So I’d like to update but i’m worried about losing my information.

Here is how I started n8n:
2023-11-10 16:52:35 docker run -it --rm --name n8n -p 5678:5678 -v ~/.n8n:/home/node/.n8n docker.n8n.io/n8nio/n8n

docker-compose file storage:
volumes:
- n8n_data:/home/node/.n8n
- /home/username/n8n-local-files:/files

I feel like if i update, i’m going to lose my current flows and credentials. as ~/.n8n is empty and so is username/n8n-local-files

So i’ve missed a step somewhere or i’m looking at this wrong. and I’ve googled docker local storage but keep getting lost.

Ah, this looks like there is a mix up. docker compose and docker run are two different things.

So I suspect what has happened here was that you were originally using docker compose with your files stored on the docker volume n8n_data. This volume is then made available to your docker compose n8n container at /home/node/.n8n through the - n8n_data:/home/node/.n8n entry in your volumes section.

Then when you started n8n using the docker run command you would have specified what’s called a bind mount where your filesystem ~/.n8n directory is made available to your docker container at /home/node/.n8n. So your container started using docker run does not use the existing volume with your workflows and credentials.

It’s not 100% clear to me what exactly is currently running on your machine. Perhaps in a first step you can run docker ps to list all running containers while you are running n8n and share the output of this command?

In a next step you could then use docker inspect -f '{{ .Mounts }}' containerName (and share the output) to take a look at the mounts for your container (replacing containerName with your actual n8n container name).

I will be on holiday next week, but perhaps @Jon can take a quick look once we know what’s going on with your current container.

docker ps:

6740014f3c2e   docker.n8n.io/n8nio/n8n            "tini -- /docker-ent…"    7 weeks ago    Up 4 weeks             127.0.0.1:5678->5678/tcp                                                                                   n8n-n8n-1
8adb53f53789   traefik                            "/entrypoint.sh --ap…"    7 weeks ago    Up 5 weeks             0.0.0.0:3002->80/tcp, :::3002->80/tcp, 0.0.0.0:6443->443/tcp, :::6443->443/tcp                             n8n-traefik-1

docker inspect:

docker inspect -f '{{ .Mounts }}' n8n-n8n-1
[{bind  /home/username/n8n-local-files /files  rw true rprivate} {volume n8n_data /var/lib/docker/volumes/n8n_data/_data /home/node/.n8n local z true }]

Hey @tkintenn,

Looking at the information the issue is you are using 2 different volumes when you use docker run you are using ~/.n8n for the user data and in compose you are using the n8n_data volume.

You will need to find out which one has the data in it from before then set the docker run command to use that volume instead.

1 Like

Looks like it’s in the volume under docker… i think?

contents of /var/lib/docker/volumes/n8n_data/_data:

/var/lib/docker/volumes/n8n_data/_data# ls -l
total 30416
drwxr-sr-x 3 username username     4096 Oct  6 16:06 binaryData
-rw-r--r-- 1 username username       56 Oct  6 16:06 config
-rw-r--r-- 1 username username        0 Dec  1 19:41 crash.journal
-rw-r--r-- 1 username username 29474816 Jan  8 12:42 database.sqlite
drwxr-sr-x 2 username username     4096 Oct  6 16:06 git
-rw-r--r-- 1 username username     8885 Dec  1 19:40 n8nEventLog-1.log
-rw-r--r-- 1 username username   144773 Dec  1 19:37 n8nEventLog-2.log
-rw-r--r-- 1 username username   463289 Nov 28 00:04 n8nEventLog-3.log
-rw-r--r-- 1 username username  1011547 Jan  8 11:05 n8nEventLog.log
drwxr-sr-x 2 username username     4096 Oct  6 16:06 ssh

contents of /home/username/n8n-local-files:

ls -l /home/username/n8n-local-files/
total 0

we hit some snags and I had to step away from this for a second.

Hey @tkintenn,

So it looks like your data is in that volume and you may need to look at the database pruning options at some point but for now if you start n8n using the n8n_data volume you will find your workflows are back.

2 Likes

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.