{
  "workflow": {
    "id": 1053,
    "name": "Git backup of workflows and credentials",
    "views": 16175,
    "recentViews": 0,
    "totalViews": 16175,
    "createdAt": "2021-04-22T19:30:19.923Z",
    "description": "This creates a git backup of the workflows and credentials.\n\nIt uses the n8n export command with git diff, so you can run as many times as you want, but only when there are changes they will create a commit.\n\n# Setup\n_You need some access to the server._\n\nCreate a repository in some remote place to host your project, like Github, Gitlab, or your favorite private repo.\n\nClone the repository in the server in a place that the n8n has access. In the example, it's the `.`, and the repository name is `repo`. Change it in the commands *and in the workflow commands* (you can set it as a variable in the wokflow). Checkout to another branch if you won't use the master one.\n\n```\ncd .\ngit clone repository\n```\n\nOr you could `git init` and then add the remote (`git remote add origin YOUR_REPO_URL`), whatever pleases you more.\n\nAs the server, check if everything is ok for beeing able to commit. Very likely you'll need to setup the user email and name. Try to create a commit, and push it to upstream, and everything you need (like config a user to comit) will appear in way. I strong suggest testing with exporting the commands to garantee it will work too.\n\n```\ncd ./repo\n\ngit commit -c \"Initial commmit\" --allow-empty\n```\n\n-u is the same as --set-upstream\n\n```sh \ngit push -u origin master \n```\n\nTesting to push to upstream with the first exported data\n\n```\nnpx n8n export:workflow --backup --output ./repo/workflows/\nnpx n8n export:credentials --backup --output repo/credentials/\n\ncd ./repo\ngit add .\ngit commit -c \"manual backup: first export\"\ngit push\n```\n\nAfter that, if everything is ok, the workflow should work just fine.\n\n## Adjustments\n\nAdjust the path in used in the workflow. See the the `git -C PATH` command is the same as `cd PATH; git ...`.\n\nAlso, adjust the cron to run as you need. As I said in the beginning, you can run it even for every minute, but it will create commits only when there are changes.\n\n### Credentials encryption\n\nThe default for exporting the credentials is to do them encrypted. You can add the flag `--decrypted` to the `n8n export:credentials` command if you need to save them in plain. But as general rule, it's better to save the encryption key, that you only need to do that once, and them export it safely encrypted.",
    "workflow": {
      "id": "15",
      "name": "Tools / Backup Gitlab",
      "nodes": [
        {
          "name": "On clicking 'execute'",
          "type": "n8n-nodes-base.manualTrigger",
          "position": [
            250,
            400
          ],
          "parameters": {},
          "typeVersion": 1
        },
        {
          "name": "Export Workflows",
          "type": "n8n-nodes-base.executeCommand",
          "position": [
            450,
            300
          ],
          "parameters": {
            "command": "npx n8n export:workflow --backup --output repo/workflows/"
          },
          "typeVersion": 1
        },
        {
          "name": "Export Credentials",
          "type": "n8n-nodes-base.executeCommand",
          "position": [
            600,
            300
          ],
          "parameters": {
            "command": "npx n8n export:credentials --backup --output repo/credentials/"
          },
          "typeVersion": 1
        },
        {
          "name": "git add",
          "type": "n8n-nodes-base.executeCommand",
          "position": [
            750,
            300
          ],
          "parameters": {
            "command": "git -C repo add ."
          },
          "typeVersion": 1
        },
        {
          "name": "git commit",
          "type": "n8n-nodes-base.executeCommand",
          "position": [
            900,
            300
          ],
          "parameters": {
            "command": "=git -C repo commit -m \"Auto backup ({{ new Date().toISOString() }})\""
          },
          "typeVersion": 1
        },
        {
          "name": "git push",
          "type": "n8n-nodes-base.executeCommand",
          "position": [
            1050,
            300
          ],
          "parameters": {
            "command": "git -C repo push"
          },
          "typeVersion": 1
        },
        {
          "name": "Cron",
          "type": "n8n-nodes-base.cron",
          "position": [
            250,
            200
          ],
          "parameters": {
            "triggerTimes": {
              "item": [
                {
                  "hour": 0
                },
                {
                  "hour": 12
                },
                {
                  "hour": 6
                },
                {
                  "hour": 18
                }
              ]
            }
          },
          "typeVersion": 1
        }
      ],
      "active": true,
      "settings": {},
      "connections": {
        "Cron": {
          "main": [
            [
              {
                "node": "Export Workflows",
                "type": "main",
                "index": 0
              }
            ]
          ]
        },
        "git add": {
          "main": [
            [
              {
                "node": "git commit",
                "type": "main",
                "index": 0
              }
            ]
          ]
        },
        "git commit": {
          "main": [
            [
              {
                "node": "git push",
                "type": "main",
                "index": 0
              }
            ]
          ]
        },
        "Export Workflows": {
          "main": [
            [
              {
                "node": "Export Credentials",
                "type": "main",
                "index": 0
              }
            ]
          ]
        },
        "Export Credentials": {
          "main": [
            [
              {
                "node": "git add",
                "type": "main",
                "index": 0
              }
            ]
          ]
        },
        "On clicking 'execute'": {
          "main": [
            [
              {
                "node": "Export Workflows",
                "type": "main",
                "index": 0
              }
            ]
          ]
        }
      }
    },
    "lastUpdatedBy": 16,
    "workflowInfo": {
      "nodeCount": 7,
      "nodeTypes": {
        "n8n-nodes-base.cron": {
          "count": 1
        },
        "n8n-nodes-base.manualTrigger": {
          "count": 1
        },
        "n8n-nodes-base.executeCommand": {
          "count": 5
        }
      }
    },
    "status": "published",
    "readyToDemo": null,
    "user": {
      "name": "Allan Daemon",
      "username": "allandaemon",
      "bio": null,
      "verified": false,
      "links": [],
      "avatar": "https://gravatar.com/avatar/1687c83a4fb8808fac61e4c2caa35aeb9e7953516a53a3d4bbfb380b83c48291?r=pg&d=retro&size=200"
    },
    "nodes": [
      {
        "id": 7,
        "icon": "fa:clock",
        "name": "n8n-nodes-base.cron",
        "codex": {
          "data": {
            "alias": [
              "Time",
              "Scheduler",
              "Polling",
              "Cron",
              "Interval"
            ],
            "details": "The Cron node uses Cron under the hood - a time-based job scheduler in Unix-like computer operating systems. Use this node when you want to trigger workflows periodically, especially in more complex scenarios like \"every Tuesday at 9 am\" or \"Weekdays\".",
            "resources": {
              "generic": [
                {
                  "url": "https://n8n.io/blog/2021-goals-level-up-your-vocabulary-with-vonage-and-n8n/",
                  "icon": "🎯",
                  "label": "2021 Goals: Level Up Your Vocabulary With Vonage and n8n"
                },
                {
                  "url": "https://n8n.io/blog/love-at-first-sight-ricardos-n8n-journey/",
                  "icon": "❤️",
                  "label": "Love at first sight: Ricardo’s n8n journey"
                },
                {
                  "url": "https://n8n.io/blog/2021-the-year-to-automate-the-new-you-with-n8n/",
                  "icon": "☀️",
                  "label": "2021: The Year to Automate the New You with n8n"
                },
                {
                  "url": "https://n8n.io/blog/why-business-process-automation-with-n8n-can-change-your-daily-life/",
                  "icon": "🧬",
                  "label": "Why business process automation with n8n can change your daily life"
                },
                {
                  "url": "https://n8n.io/blog/why-i-chose-n8n-over-zapier-in-2020/",
                  "icon": "😍",
                  "label": "Why I chose n8n over Zapier in 2020"
                },
                {
                  "url": "https://n8n.io/blog/how-to-host-virtual-coffee-breaks-with-n8n/",
                  "icon": "☕️",
                  "label": "How to host virtual coffee breaks with n8n"
                },
                {
                  "url": "https://n8n.io/blog/automatically-pulling-and-visualizing-data-with-n8n/",
                  "icon": "📈",
                  "label": "Automatically pulling and visualizing data with n8n"
                },
                {
                  "url": "https://n8n.io/blog/how-to-sync-data-between-two-systems/",
                  "icon": "🏬",
                  "label": "How to synchronize data between two systems (one-way vs. two-way sync"
                },
                {
                  "url": "https://n8n.io/blog/database-monitoring-and-alerting-with-n8n/",
                  "icon": "📡",
                  "label": "Database Monitoring and Alerting with n8n"
                },
                {
                  "url": "https://n8n.io/blog/automate-your-data-processing-pipeline-in-9-steps-with-n8n/",
                  "icon": "⚙️",
                  "label": "Automate your data processing pipeline in 9 steps"
                },
                {
                  "url": "https://n8n.io/blog/5-tasks-you-can-automate-with-notion-api/",
                  "icon": "⚡️",
                  "label": "5 tasks you can automate with the new Notion API "
                },
                {
                  "url": "https://n8n.io/blog/world-poetry-day-workflow/",
                  "icon": "📜",
                  "label": "Celebrating World Poetry Day with a daily poem in Telegram"
                },
                {
                  "url": "https://n8n.io/blog/automate-google-apps-for-productivity/",
                  "icon": "💡",
                  "label": "15 Google apps you can combine and automate to increase productivity"
                },
                {
                  "url": "https://n8n.io/blog/automate-designs-with-bannerbear-and-n8n/",
                  "icon": "🎨",
                  "label": "Automate Designs with Bannerbear and n8n"
                },
                {
                  "url": "https://n8n.io/blog/tracking-time-spent-in-meetings-with-google-calendar-twilio-and-n8n/",
                  "icon": "🗓",
                  "label": "Tracking Time Spent in Meetings With Google Calendar, Twilio, and n8n"
                },
                {
                  "url": "https://n8n.io/blog/creating-error-workflows-in-n8n/",
                  "icon": "🌪",
                  "label": "Creating Error Workflows in n8n"
                },
                {
                  "url": "https://n8n.io/blog/using-automation-to-boost-productivity-in-the-workplace/",
                  "icon": "💪",
                  "label": "Using Automation to Boost Productivity in the Workplace"
                },
                {
                  "url": "https://n8n.io/blog/why-this-product-manager-loves-workflow-automation-with-n8n/",
                  "icon": "🧠",
                  "label": "Why this Product Manager loves workflow automation with n8n"
                },
                {
                  "url": "https://n8n.io/blog/sending-automated-congratulations-with-google-sheets-twilio-and-n8n/",
                  "icon": "🙌",
                  "label": "Sending Automated Congratulations with Google Sheets, Twilio, and n8n "
                },
                {
                  "url": "https://n8n.io/blog/a-low-code-bitcoin-ticker-built-with-questdb-and-n8n-io/",
                  "icon": "📈",
                  "label": "A low-code bitcoin ticker built with QuestDB and n8n.io"
                },
                {
                  "url": "https://n8n.io/blog/benefits-of-automation-and-n8n-an-interview-with-hubspots-hugh-durkin/",
                  "icon": "🎖",
                  "label": "Benefits of automation and n8n: An interview with HubSpot's Hugh Durkin"
                },
                {
                  "url": "https://n8n.io/blog/creating-scheduled-text-affirmations-with-n8n/",
                  "icon": "🤟",
                  "label": "Creating scheduled text affirmations with n8n"
                },
                {
                  "url": "https://n8n.io/blog/how-goomer-automated-their-operations-with-over-200-n8n-workflows/",
                  "icon": "🛵",
                  "label": "How Goomer automated their operations with over 200 n8n workflows"
                }
              ],
              "primaryDocumentation": [
                {
                  "url": "https://docs.n8n.io/integrations/builtin/core-nodes/n8n-nodes-base.scheduletrigger/"
                }
              ]
            },
            "categories": [
              "Core Nodes"
            ],
            "nodeVersion": "1.0",
            "codexVersion": "1.0",
            "subcategories": {
              "Core Nodes": [
                "Flow"
              ]
            }
          }
        },
        "group": "[\"trigger\",\"schedule\"]",
        "defaults": {
          "name": "Cron",
          "color": "#29a568"
        },
        "iconData": {
          "icon": "clock",
          "type": "icon"
        },
        "displayName": "Cron",
        "typeVersion": 1,
        "nodeCategories": [
          {
            "id": 9,
            "name": "Core Nodes"
          }
        ]
      },
      {
        "id": 13,
        "icon": "fa:terminal",
        "name": "n8n-nodes-base.executeCommand",
        "codex": {
          "data": {
            "alias": [
              "Shell",
              "Command",
              "OS",
              "Bash"
            ],
            "details": "Execute command allows you to run terminal commands on the computer/server hosting your n8n instance. Useful for executing a shell script or interacting with your n8n instance programmatically via the CLI.",
            "resources": {
              "generic": [
                {
                  "url": "https://n8n.io/blog/how-uproc-scraped-a-multi-page-website-with-a-low-code-workflow/",
                  "icon": " 🕸️",
                  "label": "How uProc scraped a multi-page website with a low-code workflow"
                },
                {
                  "url": "https://n8n.io/blog/why-this-product-manager-loves-workflow-automation-with-n8n/",
                  "icon": "🧠",
                  "label": "Why this Product Manager loves workflow automation with n8n"
                }
              ],
              "primaryDocumentation": [
                {
                  "url": "https://docs.n8n.io/integrations/builtin/core-nodes/n8n-nodes-base.executecommand/"
                }
              ]
            },
            "categories": [
              "Development",
              "Core Nodes"
            ],
            "nodeVersion": "1.0",
            "codexVersion": "1.0",
            "subcategories": {
              "Core Nodes": [
                "Helpers"
              ]
            }
          }
        },
        "group": "[\"transform\"]",
        "defaults": {
          "name": "Execute Command",
          "color": "#886644"
        },
        "iconData": {
          "icon": "terminal",
          "type": "icon"
        },
        "displayName": "Execute Command",
        "typeVersion": 1,
        "nodeCategories": [
          {
            "id": 5,
            "name": "Development"
          },
          {
            "id": 9,
            "name": "Core Nodes"
          }
        ]
      },
      {
        "id": 42,
        "icon": "fa:play",
        "name": "n8n-nodes-base.start",
        "codex": {
          "data": {
            "resources": {
              "generic": [
                {
                  "url": "https://n8n.io/blog/why-business-process-automation-with-n8n-can-change-your-daily-life/",
                  "icon": "🧬",
                  "label": "Why business process automation with n8n can change your daily life"
                },
                {
                  "url": "https://n8n.io/blog/why-i-chose-n8n-over-zapier-in-2020/",
                  "icon": "😍",
                  "label": "Why I chose n8n over Zapier in 2020"
                },
                {
                  "url": "https://n8n.io/blog/automatically-pulling-and-visualizing-data-with-n8n/",
                  "icon": "📈",
                  "label": "Automatically pulling and visualizing data with n8n"
                },
                {
                  "url": "https://n8n.io/blog/how-to-use-the-http-request-node-the-swiss-army-knife-for-workflow-automation/",
                  "icon": "🧰",
                  "label": "How to use the HTTP Request Node - The Swiss Army Knife for Workflow Automation"
                },
                {
                  "url": "https://n8n.io/blog/sending-sms-the-low-code-way-with-airtable-twilio-programmable-sms-and-n8n/",
                  "icon": "📱",
                  "label": "Sending SMS the Low-Code Way with Airtable, Twilio Programmable SMS, and n8n"
                },
                {
                  "url": "https://n8n.io/blog/automating-conference-organization-processes-with-n8n/",
                  "icon": "🙋‍♀️",
                  "label": "Automating Conference Organization Processes with n8n"
                }
              ],
              "primaryDocumentation": [
                {
                  "url": "https://docs.n8n.io/integrations/builtin/core-nodes/n8n-nodes-base.start/"
                }
              ]
            },
            "categories": [
              "Core Nodes"
            ],
            "nodeVersion": "1.0",
            "codexVersion": "1.0"
          }
        },
        "group": "[\"input\"]",
        "defaults": {
          "name": "Start",
          "color": "#00e000"
        },
        "iconData": {
          "icon": "play",
          "type": "icon"
        },
        "displayName": "Start",
        "typeVersion": 1,
        "nodeCategories": [
          {
            "id": 9,
            "name": "Core Nodes"
          }
        ]
      }
    ],
    "categories": [
      {
        "id": 16,
        "name": "DevOps"
      }
    ],
    "image": []
  }
}