I found couple of threads in the community explaining ways to backup workflows to google drive and/or airtables. But looks like these mechanisms use Rest APIs that are probably not public yet (please correct me if I am wrong).
Therefore, I am not sure what’s the best way to backup my workflows. I am looking for a reliable backup solution (periodic) either to github or anywhere else that’s known to work.
I use a modified version of this workflow: https://n8n.io/workflows/817 it uses the internal APIs to update the workflows in Github. I have it running every 2 hours, Another option you could use is to use the CLI tool which has export options so you can write a script (or a workflow) to run the tool, export the workflows then commit to git.
If you go the CLI route, you can use the Execute Command node to run a script (or CLI commands directly) - so this way an n8n workflow can still power the backup process. Plus, since you have a workflow it’s then easy to add on things like a notification/ alert if the backup fails.
Hi, I’m trying to implement this in my self-hosted version of n8n, but in the “N8N Workflows” node, I’m getting the following error message: “Error: connect ECONNREFUSED”
I simply updated the URL to my n8n URL. Is there anything else that I need to do (e.g. set authentication)?
You have to change the workflow according to your need. So would you for example have to change the URL on the node “N8N Workflows”.
In the example it is set to http://localhost:8443/rest/workflows as the user who created the workflow is apparently running n8n on port 8443. In your case, it is more likely the n8n default port 5678 and the URL would so have to be changed to http://localhost:5678/rest/workflows.
Note:
port 8443 - provided me with error message: “Error: connect ECONNREFUSED”
port “5678” - says: ERROR: UNKNOWN ERROR - check the detailed error for more information - Authorization is required!
You do indeed, So you will need to set Basic Auth and use the username / password you use to access your install. Image below shows how I have mine set up.
Yeah the new user management feature doesn’t use Basic auth, There is a version of the github backup solution that uses the CLI to export instead which you could use.
Hi @Jon, I’ve got the AUTH portion working on this workflow, but having trouble getting the Function node to parse out the status (same, edit, new). I think the issue is that now the output contains new information (tags) and maybe new key names, so the function is not working correctly. Any chance someone could play with it? This is my favorite Workflow
Are you using the new public API, or the old internal one? I’ve updated mine to the public API, but was using the old one without change.
The main change I needed to make for the public API was changing from this: var n8nWorkflow = (items[1].json.data);
to this var n8nWorkflow = (items[1].json);
It does work with self hosted but the authentication is different now, If you are looking at doing backups I have updated the CLI option so it uses the public API instead which may be easier. You can find it here: Back Up Your n8n Workflows To Github | n8n workflow template