Unable to export workflows

Setup: NPM, running with Pm2 (n8n latest version)

user@n8n:~/n8n$ n8n export:workflow --all
Error exporting workflows. See log messages for details.
No workflows found with specified filters.

Logs are set to debug and nothing shows up. Any advice on how to troubleshoot

thanks in advance

Hi @wgicio, I just used the export option through the CLI but didn’t run into any trouble here.

Is your pm2 user perhaps different from the user you are running the CLI command as? By default, n8n would store data in the .n8n folder of the current user’s home directory. So, if your pm2 user is different from your command line user, the latter can’t see the data of the former.

So i am running the command under the correct user that pm2 is running the process under

–
macca@n8n:~/.n8n$ pm2 env 0
N8N_SMTP_SSL: true
N8N_LOG_FILE_MAXCOUNT: 3
N8N_LOG_FILE_MAXSIZE: 50
N8N_LOG_FILE_LOCATION: /home/macca/n8n/logs/n8n.log
N8N_LOG_OUTPUT: console,file
N8N_LOG_LEVEL: debug
N8N_USER_FOLDER: /home/macca/n8n/

just nothing showing in the log

Just try the -u

I believe -u is an option when using the docker exec command, This looks to be an npm install so I would expect using that to return an error saying something like the argument is invalid… This doesn’t help solve the issue though.

It looks like the pm2 process is running as macca which is the same as the logged user, Although maybe pm2 is doing something odd. A `ps -ef | grep n8n’ might show a different user and could be worth doing so you can see if you need to swap to a different user.

What distro are you running on @wgicio? I might be able to set up a quick test environment and see what happens.

Sorry - you are correct - it is a docker specific option.
While trying exporting for a few hours - nothing made sense to me - except it was a user context issue.
So whatever the pm2 option is - if probably the answer.

1 Like

So I’m running Ubuntu 22.04.1 LTS

macca@n8n:~$ ps -ef | grep n8n
macca        886     854  0 Dec14 ?        00:04:18 node /usr/bin/n8n
macca       8487    8475  0 00:04 pts/0    00:00:00 grep --color=auto n8n


macca@n8n:~$ n8n export:workflow --backup --output=/home/macca/n8n/temp/
Error exporting workflows. See log messages for details.
No workflows found with specified filters.
macca@n8n:~$ 

however this command runs fine from within n8n

In the Execute command node could you run whoami?

[

{

“exitCode”:0,

“stderr”:“”,

“stdout”:“macca”

}

]

1 Like

Alright so the user is right, That is very odd. I will set up a quick test environment later and see if I can work it out.

@Jon Thanks - could this export really be simplfied?
I am sure the user context is important in the current logic somehow (else you would not have it).

Can it be worked around by using the encryption key or something instead?
I know I have it working now, but it took me hours for something very simple.

Thanks

Hey @treyr,

That really depends on where the issue is, I will need to check out code to see what we are doing but my initial thought would be that when you run the command it will use the default config path for the encryption key and the database which would be ~/.n8n but when you are using say docker and you use the exec command it tends to default to a root user which wouldn’t have that key or the same database.

In this case the command is ran as the same user that the process is running as in pm2 so I assume there is something else going on that I will need to look into.

Another way to export the workflows would be to use the API or if you really wanted to you could pull them directly from the database.

There are always improvements that can be made though so maybe we need to look at an updated tool that can pull the flows using the API.

1 Like

I made this quick workflow to export the workflows to local files by date.
It DOES NOT export the credentials because the node doesnt allow that function.

How can we add this to the default templates available in the Templates folder?
The ones in there are old, too complex and do NOT use the n8n API mode.

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