AutomationFlowsGeneral › Backup n8n Workflows & Credentials to Git

Backup n8n Workflows & Credentials to Git

Original n8n title: Backup Workflows & Credentials

Backup workflows & credentials. Uses start, executeCommand. Manual trigger; 13 nodes.

Manual trigger★★★★☆ complexity13 nodesStartExecute Command
General Trigger: Manual Nodes: 13 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
{
  "id": 1,
  "name": "Backup workflows & credentials",
  "active": false,
  "nodes": [
    {
      "parameters": {},
      "name": "Start",
      "type": "n8n-nodes-base.start",
      "typeVersion": 1,
      "position": [
        -480,
        460
      ]
    },
    {
      "parameters": {
        "command": "cd $GIT_BACKUP_DIR\n\ngit push"
      },
      "name": "git push",
      "type": "n8n-nodes-base.executeCommand",
      "typeVersion": 1,
      "position": [
        840,
        460
      ],
      "alwaysOutputData": false
    },
    {
      "parameters": {
        "command": "=cd $GIT_BACKUP_DIR\ngit add workflows/*\ngit commit -m \"[Auto] Workflows {{ new Date().toISOString() }}\" workflows\n\ncode=$?\nif [ $code -eq 0 ] ; then\n  >&2 echo \"OK\"\nelse\n  >&2 echo \"KO\"\nfi"
      },
      "name": "git add & git commit",
      "type": "n8n-nodes-base.executeCommand",
      "typeVersion": 1,
      "position": [
        460,
        340
      ]
    },
    {
      "parameters": {
        "command": "=git config --global user.email \"{{$json[\"GIT_USER_EMAIL\"]}}\"\ngit config --global user.name \"{{$json[\"GIT_USER_NAME\"]}}\""
      },
      "name": "git config",
      "type": "n8n-nodes-base.executeCommand",
      "typeVersion": 1,
      "position": [
        -160,
        460
      ]
    },
    {
      "parameters": {
        "command": "cd $GIT_BACKUP_DIR\ngit fetch --all\ngit reset --hard origin/main"
      },
      "name": "git pull rebase",
      "type": "n8n-nodes-base.executeCommand",
      "typeVersion": 1,
      "position": [
        0,
        460
      ]
    },
    {
      "parameters": {
        "command": "=cd $GIT_BACKUP_DIR\ngit add credentials/*\ngit commit -m \"[Auto] Credentials {{ new Date().toISOString() }}\" credentials\ncode=$?\n\nif [ $code -eq 0 ] ; then\n  >&2 echo \"OK\"\nelse\n  >&2 echo \"KO\"\nfi"
      },
      "name": "git add & git commit1",
      "type": "n8n-nodes-base.executeCommand",
      "typeVersion": 1,
      "position": [
        480,
        540
      ]
    },
    {
      "parameters": {
        "command": "mkdir -p $GIT_BACKUP_DIR/credentials\nnpx n8n export:credentials --backup --decrypted --output $GIT_BACKUP_DIR/credentials\n\ncode=$?\nif [ $code -eq 0 ] ; then\n  >&2 echo \"OK\"\nelse\n  >&2 echo \"KO\"\nfi"
      },
      "name": "n8n export credentials",
      "type": "n8n-nodes-base.executeCommand",
      "typeVersion": 1,
      "position": [
        160,
        560
      ]
    },
    {
      "parameters": {
        "command": "mkdir -p $GIT_BACKUP_DIR/workflows\nnpx n8n export:workflow --backup --output $GIT_BACKUP_DIR/workflows\n\n\ncode=$?\nif [ $code -eq 0 ] ; then\n  >&2 echo \"OK\"\nelse\n  >&2 echo \"KO\"\nfi"
      },
      "name": "n8n export workflows",
      "type": "n8n-nodes-base.executeCommand",
      "typeVersion": 1,
      "position": [
        160,
        360
      ]
    },
    {
      "parameters": {
        "conditions": {
          "string": [
            {
              "value1": "={{$json[\"stderr\"]}}",
              "value2": "OK"
            }
          ]
        }
      },
      "name": "if export WF OK",
      "type": "n8n-nodes-base.if",
      "typeVersion": 1,
      "position": [
        300,
        360
      ]
    },
    {
      "parameters": {
        "conditions": {
          "string": [
            {
              "value1": "={{$json[\"stderr\"]}}",
              "value2": "OK"
            }
          ]
        }
      },
      "name": "if export CR OK",
      "type": "n8n-nodes-base.if",
      "typeVersion": 1,
      "position": [
        300,
        560
      ]
    },
    {
      "parameters": {
        "conditions": {
          "string": [
            {
              "value1": "={{$json[\"stderr\"]}}",
              "value2": "OK"
            }
          ]
        }
      },
      "name": "if WF is committed",
      "type": "n8n-nodes-base.if",
      "typeVersion": 1,
      "position": [
        620,
        340
      ]
    },
    {
      "parameters": {
        "conditions": {
          "string": [
            {
              "value1": "={{$json[\"stderr\"]}}",
              "value2": "OK"
            }
          ]
        }
      },
      "name": "if CR is committed",
      "type": "n8n-nodes-base.if",
      "typeVersion": 1,
      "position": [
        620,
        540
      ]
    },
    {
      "parameters": {
        "values": {
          "string": [
            {
              "name": "GIT_USER_EMAIL",
              "value": "mulugruntz@gmail.com"
            },
            {
              "name": "GIT_USER_NAME",
              "value": "n8n Backup Bot"
            }
          ]
        },
        "options": {}
      },
      "name": "Set",
      "type": "n8n-nodes-base.set",
      "typeVersion": 1,
      "position": [
        -320,
        460
      ]
    }
  ],
  "connections": {
    "Start": {
      "main": [
        [
          {
            "node": "Set",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "git config": {
      "main": [
        [
          {
            "node": "git pull rebase",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "git pull rebase": {
      "main": [
        [
          {
            "node": "n8n export workflows",
            "type": "main",
            "index": 0
          },
          {
            "node": "n8n export credentials",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "git add & git commit": {
      "main": [
        [
          {
            "node": "if WF is committed",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "git add & git commit1": {
      "main": [
        [
          {
            "node": "if CR is committed",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "n8n export credentials": {
      "main": [
        [
          {
            "node": "if export CR OK",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "n8n export workflows": {
      "main": [
        [
          {
            "node": "if export WF OK",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "if export WF OK": {
      "main": [
        [
          {
            "node": "git add & git commit",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "if export CR OK": {
      "main": [
        [
          {
            "node": "git add & git commit1",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "if WF is committed": {
      "main": [
        [
          {
            "node": "git push",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "if CR is committed": {
      "main": [
        [
          {
            "node": "git push",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Set": {
      "main": [
        [
          {
            "node": "git config",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  },
  "createdAt": "2021-11-03T11:39:59.313Z",
  "updatedAt": "2022-04-19T15:01:12.223Z",
  "settings": {},
  "staticData": null
}
Pro

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

About this workflow

Backup workflows & credentials. Uses start, executeCommand. Manual trigger; 13 nodes.

Source: https://github.com/Mulugruntz/integrator-n8n-backups/blob/b2023dec82446de023dae03cf9a1d5d397feb833/workflows/1.json — original creator credit. Request a take-down →

More General workflows → · Browse all categories →

Related workflows

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

General

VITRA Transcription Pipeline. Uses start, executeCommand, moveFiles, notification. Manual trigger; 6 nodes.

Start, Execute Command, Move Files +1
General

NextCloud:NextCloud:Folder:create move copy delete list:File:upload move copy download delete. Uses start, nextCloud, readBinaryFile. Manual trigger; 28 nodes.

Start, Next Cloud, Read Binary File
General

Transporeon - orders - step 3 - process single. Uses start, functionItem, httpRequest, microsoftSql. Manual trigger; 26 nodes.

Start, Function Item, HTTP Request +3
General

Orbit:Member:upsert get update delete getAll lookup:Note:create update getAll:Activity:create getAll:Post:create getAll delete. Uses start, orbit. Manual trigger; 16 nodes.

Start, Orbit
General

Raindrop:User:get:Collection:create get update getAll delete:Bookmark:create get update getAll delete:Tag:getAll delete. Uses start, raindrop. Manual trigger; 14 nodes.

Start, Raindrop