Lost all workflows/credentials everythig after ubuntu update

I just updated my Ubuntu sever to 22.04 and after restarting my docker-compose n8n everything has been reset… no workflows, no credentials, no everything else…

  • n8n version: 0.190.0
  • Database you’re using (default: SQLite): default
  • Running n8n with the execution process [own(default), main]: default
  • Running n8n via [Docker, npm, n8n.cloud, desktop app]: docker-compose

Welcome to the community @saachi!

Can you please share your docker-compose file. Do you have Docker experience?

Hi @jan ,

Here is my docker-compose file :

Version: "3"

    image: "traefik"
    restart: always
      - "--api=true"
      - "--api.insecure=true"
      - "--providers.docker=true"
      - "--providers.docker.exposedbydefault=false"
      - "--entrypoints.web.address=:80"
      - "--entrypoints.web.http.redirections.entryPoint.to=websecure"
      - "--entrypoints.web.http.redirections.entrypoint.scheme=https"
      - "--entrypoints.websecure.address=:443"
      - "--certificatesresolvers.mytlschallenge.acme.tlschallenge=true"
      - "--certificatesresolvers.mytlschallenge.acme.email=${SSL_EMAIL}"
      - "--certificatesresolvers.mytlschallenge.acme.storage=/letsencrypt/acme.json"
      - "80:80"
      - "443:443"
      - ${DATA_FOLDER}/letsencrypt:/letsencrypt
      - /var/run/docker.sock:/var/run/docker.sock:ro

    image: n8nio/n8n
    restart: always
      - ""
      - traefik.enable=true
      - traefik.http.routers.n8n.rule=Host(`${SUBDOMAIN}.${DOMAIN_NAME}`)
      - traefik.http.routers.n8n.tls=true
      - traefik.http.routers.n8n.entrypoints=web,websecure
      - traefik.http.routers.n8n.tls.certresolver=mytlschallenge
      - traefik.http.middlewares.n8n.headers.SSLRedirect=true
      - traefik.http.middlewares.n8n.headers.STSSeconds=315360000
      - traefik.http.middlewares.n8n.headers.browserXSSFilter=true
      - traefik.http.middlewares.n8n.headers.contentTypeNosniff=true
      - traefik.http.middlewares.n8n.headers.forceSTSHeader=true
      - traefik.http.middlewares.n8n.headers.SSLHost=${DOMAIN_NAME}
      - traefik.http.middlewares.n8n.headers.STSIncludeSubdomains=true
      - traefik.http.middlewares.n8n.headers.STSPreload=true
      - [email protected]
      - N8N_BASIC_AUTH_ACTIVE=true
      - N8N_PORT=5678
      - N8N_PROTOCOL=https
      - NODE_ENV=production
      - /home/linux01/n8n-local-files:/files

I am relatively new to Docker, so let’s say my experience is very limited :wink:

Thanks a lot.

Since your setup does not have a volume mapping for the path /home/node/.n8n, and neither is the env variable N8N_USER_FOLDER set to point to /files, you might be losing data because there is no way for n8n to persist data that would survive across restarts.

Please check volumes section in this reference docker-compose file.

As a quick solution, please add this to the volumes section for the n8n container

      - ${DATA_FOLDER}/n8n:/home/node/.n8n

But I don’t understand why during several restart of the server my data persisted and I had no problem ? How is it possible that I created yesterday a workflow, today I restarted my server, stopped and started again my docker-compose and… the workflow is still there ?

When you restart a container, the data isn’t lost.
Only if you delete a stopped container, or something on your server is pruning stopped containers, then the data is lost.

That is why I am curious to understand why all my data is lost ?
The absolute only thing I did was :
sudo apt update
sudo apt upgrade

and everything was gone…
I want to understand why, because I cannot resolve myself to start again all my work if I don’t know how to prevent this ?

it’s possible that docker compose restart or restarting the machine could have caused the data loss by cleaning up unused or stopped docker containers.

The key issue here is that your setup isn’t using persistent volumes in a way that n8n could save the data reliably.

This issue isn’t specific to n8n though, if you run any docker image, it’s highly recommended to check what path(s) that programs persists data in, and then setting up docker volumes to have all the data saved in the volumes, and not in the container.
Containers are meant to be ephemeral, and should never be used to save any important data outside of volumes.

So by using this, the volume created by n8n was located inside the container and was not persistent.
By using ${DATA_FOLDER}/.n8n:/home/node/.n8n I am making sure that the .n8n file is created on my server and therefor will be persistant ? Am I right ?
I just modified the docker-compose.yml, stopped and started the container and see a new .n8n file with binaryData, config and the SQLite database.

exactly. that’s right.

Ok thanks a lot for the excellent support !
I spent a lot of hours building several workflows, it’s my own misunderstanding of things that caused the lost of them all. Thanks to you, I understand everything a little better and will have the strength to build everything again… and make sure to save the .n8n folder to an external drive as well :upside_down_face:

1 Like

Regular backups to an external drive are always a good idea :+1:

1 Like

I sadly see almost every day issues like that. Generally very discourage people to self host n8n without experience doing that. It almost always results in extended downtime and data loss. The right solution is instead using n8n cloud. There it is on our team to make sure n8n stays up and all data is secure. It is probably more expensive when you look at the fixed monthly costs but if you calculate in downtime, issues, debug-time, data lose, peace of mind, … and much more it is always cheaper.


Will look into that when the time comes.
Thanks guys.

1 Like

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