# Backup workflows to github

**URL:** <https://community.n8n.io/t/backup-workflows-to-github/18036>\
**Category:** Questions\
**Tags:** workflow-templates\
**Created:** [September 23, 2022, 4:26pm UTC](https://community.n8n.io/t/backup-workflows-to-github/18036 "2022-09-23T16:26:39Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![roofboard](https://avatars.discourse-cdn.com/v4/letter/r/dbc845/32.png) [@roofboard](https://community.n8n.io/u/roofboard)\
**Post date:** [September 23, 2022, 4:26pm UTC](https://community.n8n.io/t/backup-workflows-to-github/18036/1 "2022-09-23T16:26:39Z")

</div>

## I would like to backup all my workflows to GitHub regularly and systematically.

Looking for some advise brainstorming here, how would you go about making a workflow which checks for diffs between your workflows and github, then commits any changes to a github repo, and adds any new workflows.

Basically runs a backup of your workflows to github.

- Do you think that is possible?

If it is possible does that open the door for two way sync allowing you to edit workflows in github and have them sync back to n8n?

---

<div class="post-metadata">

**Author:** ![Jon](https://dub1.discourse-cdn.com/n8n/user_avatar/community.n8n.io/jon/32/40174_2.png) [@Jon](https://community.n8n.io/u/Jon)\
**Post date:** [September 23, 2022, 4:31pm UTC](https://community.n8n.io/t/backup-workflows-to-github/18036/2 "2022-09-23T16:31:49Z")

</div>

Hey @roofboard,

I would probably start by using the backup template we published here: [https://n8n.io/workflows/1534/](https://n8n.io/workflows/1534/) this will take the workflows you have in n8n and commit them to a GitHub repo.

As a follow up step from there it would probably be a case of getting the workflow list from the API and Github then using the merge node to find which ones are missing and go from there.

---

<div class="post-metadata">

**Author:** ![Christel-Doudet](https://dub1.discourse-cdn.com/n8n/user_avatar/community.n8n.io/christel-doudet/32/20302_2.png) [@Christel-Doudet](https://community.n8n.io/u/Christel-Doudet)\
**Post date:** [December 15, 2022, 9:36pm UTC](https://community.n8n.io/t/backup-workflows-to-github/18036/3 "2022-12-15T21:36:38Z")

</div>

hi all, error 404

---

<div class="post-metadata">

**Author:** ![Jon](https://dub1.discourse-cdn.com/n8n/user_avatar/community.n8n.io/jon/32/40174_2.png) [@Jon](https://community.n8n.io/u/Jon)\
**Post date:** [December 16, 2022, 9:59am UTC](https://community.n8n.io/t/backup-workflows-to-github/18036/4 "2022-12-16T09:59:34Z")

</div>

Hey @Christel-Doudet,

New link is [Back Up Your n8n Workflows To Github | n8n workflow template](https://n8n.io/workflows/1534-back-up-your-n8n-workflows-to-github/) it can also be found in the templates section of n8n.

---

<div class="post-metadata">

**Author:** ![seba5496](https://dub1.discourse-cdn.com/n8n/user_avatar/community.n8n.io/seba5496/32/5754_2.png) [@seba5496](https://community.n8n.io/u/seba5496)\
**Post date:** [December 30, 2022, 8:14pm UTC](https://community.n8n.io/t/backup-workflows-to-github/18036/5 "2022-12-30T20:14:33Z")

</div>

Hey @Jon, I just copied that workflow to back up my workflows, it’s been amazing actually, but recently I got this error at the IsDifforNew node.

```auto
ERROR: Unexpected end of JSON input [line 4]
SyntaxError: Unexpected end of JSON input
    at JSON.parse (<anonymous>)
    at /usr/local/lib/node_modules/n8n/node_modules/n8n-nodes-base/dist/nodes/Code:4:27
    at /usr/local/lib/node_modules/n8n/node_modules/n8n-nodes-base/dist/nodes/Code:44:2
    at VM2 Wrapper.apply (/usr/local/lib/node_modules/n8n/node_modules/vm2/lib/bridge.js:485:11)
    at Sandbox.run (/usr/local/lib/node_modules/n8n/node_modules/vm2/lib/nodevm.js:426:23)
    at Sandbox.runCodeAllItems (/usr/local/lib/node_modules/n8n/node_modules/n8n-nodes-base/nodes/Code/Sandbox.ts:76:33)
    at Sandbox.runCode (/usr/local/lib/node_modules/n8n/node_modules/n8n-nodes-base/nodes/Code/Sandbox.ts:43:56)
    at Object.execute (/usr/local/lib/node_modules/n8n/node_modules/n8n-nodes-base/nodes/Code/Code.node.ts:90:27)
    at Workflow.runNode (/usr/local/lib/node_modules/n8n/node_modules/n8n-workflow/src/Workflow.ts:1270:42)
    at /usr/local/lib/node_modules/n8n/node_modules/n8n-core/src/WorkflowExecute.ts:939:44

```

It appears as the same in the logs.

```auto
{"level":"debug","message":"Running node \"isDiffOrNew\" finished with error","metadata":{"file":"WorkflowExecute.js","node":"isDiffOrNew","timestamp":"2022-12-30T19:43:19.956Z","workflowId":"82"}}

{"level":"verbose","message":"Workflow execution finished with error","metadata":{"error":{"description":"SyntaxError","lineNumber":4,"message":"Unexpected end of JSON input [line 4]","stack":"SyntaxError: Unexpected end of JSON input\n at JSON.parse (<anonymous>)\n    
at /usr/local/lib/node_modules/n8n/node_modules/n8n-nodes-base/dist/nodes/Code:4:27\n    
at /usr/local/lib/node_modules/n8n/node_modules/n8n-nodes-base/dist/nodes/Code:44:2\n   
at VM2 Wrapper.apply (/usr/local/lib/node_modules/n8n/node_modules/vm2/lib/bridge.js:485:11)\n   
at Sandbox.run (/usr/local/lib/node_modules/n8n/node_modules/vm2/lib/nodevm.js:426:23)\n    
at Sandbox.runCodeAllItems (/usr/local/lib/node_modules/n8n/node_modules/n8n-nodes-base/nodes/Code/Sandbox.ts:76:33)\n    
at Sandbox.runCode (/usr/local/lib/node_modules/n8n/node_modules/n8n-nodes-base/nodes/Code/Sandbox.ts:43:56)\n    
at Object.execute (/usr/local/lib/node_modules/n8n/node_modules/n8n-nodes-base/nodes/Code/Code.node.ts:90:27)\n   
at Workflow.runNode (/usr/local/lib/node_modules/n8n/node_modules/n8n-workflow/src/Workflow.ts:1270:42)\n    
at /usr/local/lib/node_modules/n8n/node_modules/n8n-core/src/WorkflowExecute.ts:939:44"},"file":"WorkflowExecute.js","function":"processSuccessExecution","timestamp":"2022-12-30T19:43:19.960Z","workflowId":"82"}}

```

It is most likely a parse error because of some weird characters present in the workflows, but I haven’t managed to find the culprit line in the workflow that throws the error. I thought it may be the pinned data on those workflows, since they have emojis and Spanish characters, but I unpinned it and the same error appears.  
Any ideas on how to know which one is it?  
I appreciate the help,  
thanks. 😃

---

<div class="post-metadata">

**Author:** ![Jon](https://dub1.discourse-cdn.com/n8n/user_avatar/community.n8n.io/jon/32/40174_2.png) [@Jon](https://community.n8n.io/u/Jon)\
**Post date:** [January 3, 2023, 10:00am UTC](https://community.n8n.io/t/backup-workflows-to-github/18036/6 "2023-01-03T10:00:44Z")

</div>

Hey @seba5496,

It looks like it is something in workflow 82, I am not sure what it is not happy with but hopefully knowing the workflow will help.

---

<div class="post-metadata">

**Author:** ![MutedJam](https://dub1.discourse-cdn.com/n8n/user_avatar/community.n8n.io/mutedjam/32/70851_2.png) [@MutedJam](https://community.n8n.io/u/MutedJam)\
**Post date:** [April 3, 2023, 10:01am UTC](https://community.n8n.io/t/backup-workflows-to-github/18036/7 "2023-04-03T10:01:20Z")

</div>

Closed on April 3, 2023, 10:01am UTC

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