CLI list and export problems

Hello N8N!

I want to export my workflows and credentials. I dicovered the CLI options. But I can not get it to work.
I log into the docker container via docker exec -it n8n sh.

There I want to verify the list of workflows:

/data # n8n list:workflow
/data #

The list is empty. I also am not able to export the workflows via

/data # n8n export:workflow --backup --output=/data/
Error exporting workflows. See log messages for details.
No workflows found with specified filters.

What am I missing?

Hey @vuchl,

I think the directory you are in is incorrect. I also ran into the same error as you. However, I ran the command n8n list:workflow in the Execute Command node, and it returned the expected output. I will investigate further and get back to you.

Hey @harshil1712 !

Thanks for the suggestion. You are right. In the Execute Node it works pretty well. I used pwd to get the working directory of the process and it shows /data.

So now I have no clue why it is not working on the CLI it self. Any way I will just use the node to make my backups.

Welp, running n8n list:workflow works via the node. But using the backup flag and/or output flag fails.

Cheers

Hey @vuchl,

Running it directly via the Docker CLI, we are running it as a root user. Instead use the command su -c "n8n list:workflow" node. Similarly, when running the export command you need to set the output to a writable folder - su -c "n8n export:workflow --backup --output=/home/node/backups" node

It may be worth having a look at the example workflows there are a few for backups the one I use commits the workflows to Git (credentials I am not worried about as anything important is in a key manager).

Might as well use n8n to automate backing up itself :slightly_smiling_face:

This is the one I use if it helps: https://n8n.io/workflows/817

1 Like

fyi you can also specify the user with the docker comand via -u node like for example:

# Assuming its name is "myn8n"
docker exec -it -u node myn8n n8n export:workflow --all
3 Likes