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.
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.
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:~$
@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.
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.
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.