After a period of reflection, I started to pick up n8n again. First of all my compliments to the n8n team: it looks like you haven’t been just spinning thumbs for the last half year!
I also noticed, that since desktop app v 1.4.0 (n8n 0.174.0) my backup is no longer working. My backup workflow was basis on localhost:5679/rest/workflows and …/rest/credentials. Unfortunately, this no longer works, as instead of the json data, I’m now getting ‘Unauthorized’. I’ve tried via basic authentication, but that does not work either.
Does anybody know how to fix this?
And yes, I know that there is now a public API, and of course I want to upgrade to this method, but for now, I’ve got two reasons to get the existing workflow up and running:
I want to get my backup system up and running asap
I want to be able to backup my credentials, which (as far as I can see now) is not possible via the api
Hi @dickhoning, good to see you again. The authentication options have changed a bit and with these endpoints intended for internal use there is no official documentation. However, @pemontto shared a great example of how to authenticate against the internal API which should help you get started:
Let me know if you run into any trouble with this.
Hi @MutedJam , thanks for pointing this out to me. Unfortunately, I can not get @pemontto 's solution to work. Keep getting error 401. Since the REST functionality is undocumented, I’m probably going to rebuild my backup routine with n8n’s API. The only question remaining, is how can I backup my credentials? Or is there perhaps a simple solution to backup the relevant SQL tables? Thanks again!
Hi @Jon thanks! Just gave it a spin, and this is what I’m getting:
[email protected] ~ % /Applications/n8n.app/Contents/Resources/app/node_modules/n8n/bin/n8n export:workflow --backup --output=/Users/dick/Temp/n8n/Backups
Error exporting workflows. See log messages for details.
SQLite package has not been found installed. Try to install it: npm install sqlite3 --save
That is a bit odd and mildly annoying, I suspect I have not ran into that one before because I have that package installed I will need to do some testing on that one. I guess if you have npm installed doing an npm install sqlite3 -g would probably solve the issue but it should really work.
Hi Jon, thanks for looking into this for me. In the meantime, I looked at the rest option again. When I try the following in a webbrowser, it works fine, as follows:
Now I’m just wondering how to reproduce this behaviour in n8n. I looked at Credential unauthorized - #3 by pemontto but can not get this to work. Not in the latest version of the n8n desktop app, nor in Postman …
You can disable it by setting N8N_USER_MANAGEMENT_DISABLED to true in the desktop env file, On Mac it will be ~/.n8n/n8n-desktop.env, Then once set run the n8n user-management:reset command to reset it.
You can also send the login request in that first node if needed so you would do a post request to /rest/login and send a body that contains 2 fields email and password the second node from the other workflow would then work with the same output.
The downside to this one though would be you would have those credentials in the workflow so you would need to make sure you exclude that workflow from your backup.
Hi @Jon thanks again for trying to help me on this one. I followed your instructions, but now run into an error trying to reset user management via the command line. I then installed sqlite3, but still keep getting the same error …
Last login: Sat Nov 5 08:07:18 on ttys002
[email protected] ~ % /Applications/n8n.app/Contents/Resources/app/node_modules/n8n/bin/n8n user-management:reset
Error resetting database. See log messages for details.
SQLite package has not been found installed. Try to install it: npm install sqlite3 --save
[email protected] ~ % npm install sqlite3 -g
npm WARN deprecated @npmcli/[email protected]: This functionality has been moved to @npmcli/fs
changed 104 packages, and audited 105 packages in 3s
5 packages are looking for funding
run `npm fund` for details
found 0 vulnerabilities
[email protected] ~ % /Applications/n8n.app/Contents/Resources/app/node_modules/n8n/bin/n8n user-management:reset
Error resetting database. See log messages for details.
SQLite package has not been found installed. Try to install it: npm install sqlite3 --save
[email protected] ~ %
Hi @dickhoning, tbh I think at this stage it would make sense to switch to a different deployment method.
I am not very familiar with MacOS, so I can’t really say why sqlite3 is acting up on your machine. You shouldn’t have this problem with docker though as the pre-built n8n image includes everything needed to run n8n.
Assuming you have Docker installed, running n8n would be as simple as executing the below command in your terminal:
@MutedJam thanks for your suggestion. I actually prefer to use n8n both via Docker as well as via the App. The App gives me the possibility to create workflows that act on macOS.
As to starting my Docker container of n8n, is use the following code:
I use a different folder (~/.n8nDocker) so that the Desktop App and Docker container each have their own database/workflows.
The option --restart unless stopped together with ‘Start Docker Desktop when you log in’ makes sure that n8n is always running, even if the macOS restarts after power failure.
You can use the webhook tunnel with the docker version of n8n as well, check out the docs for an example. This would use the same tunnel mechanism also used by the desktop app (so nothing we’d recommend for production use cases).
Reading/writing binary files also works through docker, but requires that you make your local directory available as a volume inside the docker container. The command shared above already does this for your local ~/.n8n directory. By using the -v ~/.n8n:/home/node/.n8n option, the local ~/.n8n directory becomes available inside the n8n container as /home/node/.n8n. This allows the docker version of n8n to read the local n8n database and access the same workflows as the desktop app (or an npm deployment).
You can add more directories as needed by adding multiple -v parameters. For example, if you wanted to make your local directory ~/customer_files available inside the n8n container as /files, you could add -v ~/customer_files:/files to your docker run command.
This restriction would also apply to the desktop app though. The tunnel server is something we provide free of charge and doesn’t come with any uptime or availability guarantees. For a production solution you’d want to host n8n on a webserver with a static domain name.