AutomationFlowsDevOps › N8n Backup

N8n Backup

n8n-backup. Uses github, n8n. Event-driven trigger; 14 nodes.

Event trigger★★★★☆ complexity14 nodesGitHubn8n
DevOps Trigger: Event Nodes: 14 Complexity: ★★★★☆ Added:

The workflow JSON

Copy or download the full n8n JSON below. Paste it into a new n8n workflow, add your credentials, activate. Full import guide →

Download .json
{
  "active": true,
  "connections": {
    "On clicking 'execute'": {
      "main": [
        [
          {
            "node": "Globals",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "GitHub": {
      "main": [
        [
          {
            "node": "Merge",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "same": {
      "main": [
        [
          {
            "node": "OneAtATime",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "different": {
      "main": [
        [
          {
            "node": "GitHub Edit",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "new": {
      "main": [
        [
          {
            "node": "GitHub Create",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "GitHub Edit": {
      "main": [
        [
          {
            "node": "OneAtATime",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "GitHub Create": {
      "main": [
        [
          {
            "node": "OneAtATime",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "OneAtATime": {
      "main": [
        [
          {
            "node": "GitHub",
            "type": "main",
            "index": 0
          },
          {
            "node": "Merge",
            "type": "main",
            "index": 1
          }
        ]
      ]
    },
    "Globals": {
      "main": [
        [
          {
            "node": "n8n",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "n8n": {
      "main": [
        [
          {
            "node": "OneAtATime",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "isDiffOrNew": {
      "main": [
        [
          {
            "node": "check_github_status",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Merge": {
      "main": [
        [
          {
            "node": "isDiffOrNew",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "check_github_status": {
      "main": [
        [
          {
            "node": "same",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "different",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "new",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "backup every 10 minutes": {
      "main": [
        [
          {
            "node": "Globals",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  },
  "createdAt": "2024-05-22T04:19:10.551Z",
  "id": "afEY6BzbqxK947MY",
  "meta": {
    "templateCredsSetupCompleted": true
  },
  "name": "n8n-backup",
  "nodes": [
    {
      "parameters": {},
      "id": "4bf78417-ae70-4f1d-9f2b-108060bea9ba",
      "name": "On clicking 'execute'",
      "type": "n8n-nodes-base.manualTrigger",
      "position": [
        -1265,
        595
      ],
      "typeVersion": 1
    },
    {
      "parameters": {
        "authentication": "oAuth2",
        "resource": "file",
        "operation": "get",
        "owner": {
          "__rl": true,
          "value": "anilrajrimal1",
          "mode": "name"
        },
        "repository": {
          "__rl": true,
          "value": "n8n-backups",
          "mode": "list",
          "cachedResultName": "n8n-backups",
          "cachedResultUrl": "https://github.com/anilrajrimal1/n8n-backups"
        },
        "filePath": "={{$node[\"Globals\"].json[\"repo\"][\"path\"]}}{{$json[\"name\"]}}.json",
        "asBinaryProperty": false,
        "additionalParameters": {}
      },
      "id": "5699c905-74e4-4a78-b4e0-1eb7898e35a6",
      "name": "GitHub",
      "type": "n8n-nodes-base.github",
      "position": [
        -420,
        560
      ],
      "typeVersion": 1,
      "alwaysOutputData": true,
      "credentials": {
        "githubOAuth2Api": {
          "name": "<your credential>"
        }
      },
      "continueOnFail": true
    },
    {
      "parameters": {},
      "id": "9bff085a-b322-40f2-8f70-694b9924cff3",
      "name": "same",
      "type": "n8n-nodes-base.noOp",
      "position": [
        460,
        460
      ],
      "typeVersion": 1
    },
    {
      "parameters": {},
      "id": "5378aaef-403c-47ad-a5d2-9fab5cba20fc",
      "name": "different",
      "type": "n8n-nodes-base.noOp",
      "position": [
        460,
        700
      ],
      "typeVersion": 1
    },
    {
      "parameters": {},
      "id": "e8a0d790-52f4-4d0b-b623-ff496864a9d3",
      "name": "new",
      "type": "n8n-nodes-base.noOp",
      "position": [
        460,
        880
      ],
      "typeVersion": 1
    },
    {
      "parameters": {
        "authentication": "oAuth2",
        "resource": "file",
        "operation": "edit",
        "owner": {
          "__rl": true,
          "value": "anilrajrimal1",
          "mode": "name"
        },
        "repository": {
          "__rl": true,
          "value": "n8n-backups",
          "mode": "list",
          "cachedResultName": "n8n-backups",
          "cachedResultUrl": "https://github.com/anilrajrimal1/n8n-backups"
        },
        "filePath": "={{$node[\"Globals\"].json[\"repo\"][\"path\"]}}{{$node[\"OneAtATime\"].json[\"name\"]}}.json",
        "fileContent": "={{$node[\"isDiffOrNew\"].json[\"n8n_data_stringy\"]}}",
        "commitMessage": "=update: n8n backup {{$node[\"OneAtATime\"].json[\"name\"]}}.json ({{$json[\"github_status\"]}})"
      },
      "id": "df61b005-12e2-41fd-9c0d-7c34248aaab8",
      "name": "GitHub Edit",
      "type": "n8n-nodes-base.github",
      "position": [
        640,
        700
      ],
      "typeVersion": 1,
      "credentials": {
        "githubOAuth2Api": {
          "name": "<your credential>"
        }
      }
    },
    {
      "parameters": {
        "authentication": "oAuth2",
        "resource": "file",
        "owner": {
          "__rl": true,
          "value": "anilrajrimal1",
          "mode": "name"
        },
        "repository": {
          "__rl": true,
          "value": "n8n-backups",
          "mode": "list",
          "cachedResultName": "n8n-backups",
          "cachedResultUrl": "https://github.com/anilrajrimal1/n8n-backups"
        },
        "filePath": "={{$node[\"Globals\"].json[\"repo\"][\"path\"]}}{{$node[\"OneAtATime\"].json[\"name\"]}}.json",
        "fileContent": "={{$node[\"isDiffOrNew\"].json[\"n8n_data_stringy\"]}}",
        "commitMessage": "=Add: n8n backup file named {{$node[\"OneAtATime\"].json[\"name\"]}}.json ({{$json[\"github_status\"]}})"
      },
      "id": "c41e0b7a-f26f-4ea8-8142-08ab08b4918a",
      "name": "GitHub Create",
      "type": "n8n-nodes-base.github",
      "position": [
        640,
        880
      ],
      "typeVersion": 1,
      "credentials": {
        "githubOAuth2Api": {
          "name": "<your credential>"
        }
      }
    },
    {
      "parameters": {
        "batchSize": 1,
        "options": {}
      },
      "id": "9d0aefa0-b8e0-428d-94d4-eb7950d34d80",
      "name": "OneAtATime",
      "type": "n8n-nodes-base.splitInBatches",
      "position": [
        -640,
        720
      ],
      "typeVersion": 1
    },
    {
      "parameters": {
        "values": {
          "string": [
            {
              "name": "repo.owner",
              "value": "n8n-io"
            },
            {
              "name": "repo.name",
              "value": "n8n-backups"
            },
            {
              "name": "repo.path",
              "value": "workflows/"
            }
          ]
        },
        "options": {}
      },
      "id": "53f7496d-5c53-499a-8de9-039ecd45b7d0",
      "name": "Globals",
      "type": "n8n-nodes-base.set",
      "position": [
        -1080,
        720
      ],
      "typeVersion": 1
    },
    {
      "parameters": {
        "filters": {}
      },
      "id": "47da53d5-af0a-47e1-a98e-697f70d39421",
      "name": "n8n",
      "type": "n8n-nodes-base.n8n",
      "position": [
        -840,
        720
      ],
      "typeVersion": 1,
      "credentials": {
        "n8nApi": {
          "name": "<your credential>"
        }
      }
    },
    {
      "parameters": {
        "jsCode": "// File Returned with Content\nif (Object.keys($input.all()[0].json).includes(\"content\")) {\n  // Get JSON Objects\n  var origWorkflow = JSON.parse(Buffer.from($input.all()[0].json.content, 'base64'));\n  var n8nWorkflow = $input.all()[1].json;\n  \n  // Order JSON Objects\n  var orderedOriginal = {}\n  var orderedActual = {}\n  \n  Object.keys(origWorkflow).sort().forEach(function(key) {\n    orderedOriginal[key] = origWorkflow[key];\n  });\n  \n  Object.keys(n8nWorkflow).sort().forEach(function(key) {\n    orderedActual[key] = n8nWorkflow[key];\n  });\n\n  // Determine Difference\n  if ( JSON.stringify(orderedOriginal) === JSON.stringify(orderedActual) ) {\n    $input.all()[0].json.github_status = \"same\";\n    $input.all()[0].json.content_decoded = orderedOriginal;\n  } else {\n    $input.all()[0].json.github_status = \"different\";\n    $input.all()[0].json.content_decoded = orderedOriginal;\n    $input.all()[0].json.n8n_data_stringy = JSON.stringify(orderedActual, null, 2);\n  }\n// No File Returned / New Workflow\n} else {\n  // Order JSON Object\n  var n8nWorkflow = ($input.all()[1].json);\n  var orderedActual = {}\n  Object.keys(n8nWorkflow).sort().forEach(function(key) {\n    orderedActual[key] = n8nWorkflow[key];\n  });\n  \n  // Proper Formatting\n  $input.all()[0].json.github_status = \"new\";\n  $input.all()[0].json.n8n_data_stringy = JSON.stringify(orderedActual, null, 2);\n}\n\n// Return Items\nreturn $input.all();"
      },
      "id": "27cfb5d2-fad5-460b-8a3b-4161cf835daf",
      "name": "isDiffOrNew",
      "type": "n8n-nodes-base.code",
      "position": [
        -20,
        700
      ],
      "typeVersion": 1
    },
    {
      "parameters": {},
      "id": "9fc95da6-fdb0-429e-bf24-e7d97e3c187f",
      "name": "Merge",
      "type": "n8n-nodes-base.merge",
      "position": [
        -200,
        700
      ],
      "typeVersion": 2
    },
    {
      "parameters": {
        "dataType": "string",
        "value1": "={{$json[\"github_status\"]}}",
        "rules": {
          "rules": [
            {
              "value2": "same"
            },
            {
              "value2": "different",
              "output": 1
            },
            {
              "value2": "new",
              "output": 2
            }
          ]
        }
      },
      "id": "d84e8997-c3d0-4df8-b211-03b59ae08b0c",
      "name": "check_github_status",
      "type": "n8n-nodes-base.switch",
      "position": [
        220,
        700
      ],
      "typeVersion": 1
    },
    {
      "parameters": {
        "triggerTimes": {
          "item": [
            {
              "mode": "everyX",
              "value": 10,
              "unit": "minutes"
            }
          ]
        }
      },
      "id": "b3b9bd82-51e3-4f3b-9d08-7a589c4b71ec",
      "name": "backup every 10 minutes",
      "type": "n8n-nodes-base.cron",
      "position": [
        -1265,
        855
      ],
      "typeVersion": 1
    }
  ],
  "settings": {
    "executionOrder": "v1"
  },
  "staticData": null,
  "tags": [],
  "triggerCount": 1,
  "updatedAt": "2024-10-21T03:48:15.000Z",
  "versionId": "e71f7d32-c42d-4f22-a8de-212b51b59831"
}

Credentials you'll need

Each integration node will prompt for credentials when you import. We strip credential IDs before publishing — you'll add your own.

Pro

For the full experience including quality scoring and batch install features for each workflow upgrade to Pro

About this workflow

n8n-backup. Uses github, n8n. Event-driven trigger; 14 nodes.

Source: https://github.com/anilrajrimal1/n8n-backups/blob/19c71696f5cfa1419600ac6bc37788c4871e69f3/workflows/n8n-backup.json — original creator credit. Request a take-down →

More DevOps workflows → · Browse all categories →

Related workflows

Workflows that share integrations, category, or trigger type with this one. All free to copy and import.

DevOps

This template lets you selectively import n8n workflows from a GitHub repository, even when your repository uses deeply nested folder structures.

Form Trigger, GitHub, n8n +1
DevOps

Code Github. Uses manualTrigger, stickyNote, n8n, httpRequest. Event-driven trigger; 25 nodes.

n8n, HTTP Request, GitHub +1
DevOps

Code Github. Uses manualTrigger, stickyNote, n8n, httpRequest. Event-driven trigger; 23 nodes.

n8n, HTTP Request, GitHub +1
DevOps

Backup-N8N-Workflows. Uses github, n8n. Event-driven trigger; 21 nodes.

GitHub, n8n
DevOps

github. Uses github, itemLists, n8n, moveBinaryData. Event-driven trigger; 18 nodes.

GitHub, Item Lists, n8n +1