n8nワークフローの自動バックアップ(ユーザー名で分類されたGitLab)

中級

これはDevOps分野の自動化ワークフローで、15個のノードを含みます。主にIf, N8n, Set, Wait, Gitlabなどのノードを使用。 n8nワークフローのバックアップ(ユーザー名別にGitLabで整理)

前提条件
  • GitLab Personal Access Token

カテゴリー

ワークフロープレビュー
ノード接続関係を可視化、ズームとパンをサポート
ワークフローをエクスポート
以下のJSON設定をn8nにインポートして、このワークフローを使用できます
{
  "id": "5ZZy57tVLfqtQZfF",
  "meta": {
    "instanceId": "dd69efaf8212c74ad206700d104739d3329588a6f3f8381a46a481f34c9cc281",
    "templateCredsSetupCompleted": true
  },
  "name": "Automated Backup of n8n Workflows to GitLab Organized by Username",
  "tags": [],
  "nodes": [
    {
      "id": "79975f6a-5aa3-4452-ba09-b489eb8c197e",
      "name": "手動バックアップトリガー",
      "type": "n8n-nodes-base.manualTrigger",
      "position": [
        -820,
        35
      ],
      "parameters": {},
      "typeVersion": 1
    },
    {
      "id": "2d5d5165-ba45-410c-8c5a-37c142b24cc1",
      "name": "週次スケジュールバックアップ",
      "type": "n8n-nodes-base.scheduleTrigger",
      "position": [
        -820,
        235
      ],
      "parameters": {
        "rule": {
          "interval": [
            {
              "field": "weeks",
              "triggerAtDay": [
                5
              ],
              "triggerAtHour": 18
            }
          ]
        }
      },
      "notesInFlow": false,
      "typeVersion": 1.2
    },
    {
      "id": "6662cc05-fe42-4f80-a59a-ba670ed143f2",
      "name": "N8N ワークフローの取得",
      "type": "n8n-nodes-base.n8n",
      "position": [
        -600,
        135
      ],
      "parameters": {
        "filters": {},
        "requestOptions": {}
      },
      "credentials": {
        "n8nApi": {
          "id": "IAN18QKBV0noRrm4",
          "name": "n8n account - test"
        }
      },
      "typeVersion": 1
    },
    {
      "id": "08d1c5cc-725b-4c9b-a7e4-55df5cd74a27",
      "name": "バックアップメタデータの準備",
      "type": "n8n-nodes-base.set",
      "position": [
        -380,
        135
      ],
      "parameters": {
        "options": {},
        "assignments": {
          "assignments": [
            {
              "id": "backup-date",
              "name": "backupDate",
              "type": "string",
              "value": "={{ $now.setZone('UTC').toFormat('yyyy-MM-dd') }}"
            },
            {
              "id": "backup-path",
              "name": "backupPath",
              "type": "string",
              "value": "=backups/{{ $now.setZone('UTC').toFormat('yyyy') }}/{{ $now.setZone('UTC').toFormat('MM') }}"
            }
          ]
        },
        "includeOtherFields": true
      },
      "typeVersion": 3.3
    },
    {
      "id": "cbae944a-2622-4ae7-99c1-56efc56d07cf",
      "name": "各ワークフローの処理",
      "type": "n8n-nodes-base.splitInBatches",
      "position": [
        -160,
        135
      ],
      "parameters": {
        "options": {}
      },
      "typeVersion": 3
    },
    {
      "id": "693af3e9-5e9c-44c6-84a3-9a7c7dcca189",
      "name": "GitLab 向けワークフローのフォーマット",
      "type": "n8n-nodes-base.set",
      "position": [
        60,
        -140
      ],
      "parameters": {
        "options": {},
        "assignments": {
          "assignments": [
            {
              "id": "workflow-data",
              "name": "workflowData",
              "type": "object",
              "value": "={{\n  {\n    \"id\": $json.id,\n    \"name\": $json.name,\n    \"active\": $json.active,\n    \"nodes\": $json.nodes,\n    \"connections\": $json.connections,\n    \"settings\": $json.settings,\n    \"staticData\": $json.staticData,\n    \"tags\": $json.tags,\n    \"versionId\": $json.versionId,\n    \"triggerCount\": $json.triggerCount,\n    \"createdAt\": $json.createdAt,\n    \"updatedAt\": $json.updatedAt\n  }\n}}"
            },
            {
              "id": "creator-name",
              "name": "creatorName",
              "type": "string",
              "value": "={{ $json.name.toLowerCase().includes('vrushti') ? 'vrushti' : $json.name.toLowerCase().includes('poojan') ? 'poojan' : $json.name.toLowerCase().includes('pragnesh') ? 'pragnesh' : $json.name.toLowerCase().includes('ajay') ? 'ajay' : 'general' }}"
            },
            {
              "id": "file-name",
              "name": "fileName",
              "type": "string",
              "value": "={{ $json.name.replace(/[^a-zA-Z0-9\\-_]/g, '_').replace(/_+/g, '_').replace(/^_|_$/g, '') }}.json"
            },
            {
              "id": "file-path",
              "name": "filePath",
              "type": "string",
              "value": "=n8n-workflows/{{ $json.name.toLowerCase().includes('vrushti') ? 'vrushti' : $json.name.toLowerCase().includes('poojan') ? 'poojan' : $json.name.toLowerCase().includes('pragnesh') ? 'pragnesh' : $json.name.toLowerCase().includes('ajay') ? 'ajay' : 'general' }}/{{ $json.name.replace(/[^a-zA-Z0-9\\-_]/g, '_').replace(/_+/g, '_').replace(/^_|_$/g, '') }}.json"
            }
          ]
        },
        "includeOtherFields": true
      },
      "typeVersion": 3.3
    },
    {
      "id": "dea22b1e-e1b3-4440-b757-ba70339950de",
      "name": "レート制限制御",
      "type": "n8n-nodes-base.wait",
      "position": [
        280,
        -140
      ],
      "webhookId": "c06823b0-4637-4e20-9c10-e020b3a74649",
      "parameters": {
        "amount": 2
      },
      "typeVersion": 1.1
    },
    {
      "id": "419a3294-fe3c-41e8-a863-3b9143c8fbba",
      "name": "バックアップ状態の確認",
      "type": "n8n-nodes-base.if",
      "position": [
        720,
        -140
      ],
      "parameters": {
        "options": {},
        "conditions": {
          "options": {
            "version": 2,
            "leftValue": "",
            "caseSensitive": true,
            "typeValidation": "strict"
          },
          "combinator": "and",
          "conditions": [
            {
              "id": "6edbebb3-1dc9-4e70-bd4b-0c02e6574808",
              "operator": {
                "name": "filter.operator.equals",
                "type": "string",
                "operation": "equals"
              },
              "leftValue": "={{ $json.error }}",
              "rightValue": "Bad request - please check your parameters"
            }
          ]
        }
      },
      "typeVersion": 2.2
    },
    {
      "id": "bf9ad468-20ad-412a-aceb-034e06795780",
      "name": "バックアップ結果の記録",
      "type": "n8n-nodes-base.set",
      "position": [
        60,
        60
      ],
      "parameters": {
        "options": {},
        "assignments": {
          "assignments": [
            {
              "id": "error-log",
              "name": "errorLog",
              "type": "string",
              "value": "=Failed to process {{ $json.fileName }}: {{ $json.error?.message || 'Unknown error' }}"
            },
            {
              "id": "success-log",
              "name": "successLog",
              "type": "string",
              "value": "=Successfully processed {{ $json.fileName }} for {{ $json.creatorName }}"
            }
          ]
        },
        "includeOtherFields": true
      },
      "typeVersion": 3.3
    },
    {
      "id": "7d67c031-8c4a-409b-9c7e-69775b28abf1",
      "name": "バックアップ要約の更新",
      "type": "n8n-nodes-base.gitlab",
      "position": [
        940,
        35
      ],
      "parameters": {
        "owner": "gitlab-user",
        "branch": "main",
        "filePath": "={{ $('Rate Limit Control').item.json.filePath }}",
        "resource": "file",
        "operation": "edit",
        "repository": "n8n-backup",
        "fileContent": "={{ JSON.stringify( $('Rate Limit Control').item.json.workflowData, null, 2) }}",
        "commitMessage": "=Update {{ $('Rate Limit Control').item.json.fileName }} in {{ $('Rate Limit Control').item.json.creatorName }} folder via n8n automation"
      },
      "credentials": {
        "gitlabApi": {
          "id": "F4ZDDauIbw2lHATd",
          "name": "GitLab account - test "
        }
      },
      "typeVersion": 1,
      "continueOnFail": true
    },
    {
      "id": "52424bd4-cbce-44a9-ab17-ddf1a910a5b9",
      "name": "メール送信",
      "type": "n8n-nodes-base.emailSend",
      "position": [
        280,
        60
      ],
      "webhookId": "c2139c63-5ead-4606-b54f-1d94f77d1b20",
      "parameters": {
        "text": "Hello,\n\nThe scheduled backup of all n8n workflows has been completed successfully.\n\nAll workflows have been committed to the GitLab repository without any errors.\n\nRegards,\nn8n Automation Bot",
        "options": {},
        "subject": "n8n workflows backup notification",
        "toEmail": "abc.gmail.com",
        "fromEmail": "xyz@gmail.com",
        "emailFormat": "text"
      },
      "credentials": {
        "smtp": {
          "id": "G1kyF8cSWTZ4vouN",
          "name": "SMTP -test"
        }
      },
      "typeVersion": 2.1
    },
    {
      "id": "5447ade3-d338-4341-ac86-36e1c1379f5f",
      "name": "GitLab リポジトリへの作成",
      "type": "n8n-nodes-base.gitlab",
      "position": [
        500,
        -140
      ],
      "parameters": {
        "owner": "gitlab-user",
        "branch": "main",
        "filePath": "={{ $json.filePath }}",
        "resource": "file",
        "repository": "n8n-backup",
        "fileContent": "={{ JSON.stringify($json.workflowData, null, 2) }}",
        "commitMessage": "=Add  {{ $json.fileName }} - {{ $json.creatorName }} folder via n8n automation"
      },
      "credentials": {
        "gitlabApi": {
          "id": "F4ZDDauIbw2lHATd",
          "name": "GitLab account - test "
        }
      },
      "typeVersion": 1,
      "continueOnFail": true
    },
    {
      "id": "bf1d778c-2363-46da-8197-2fc673b0b258",
      "name": "付箋",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -900,
        -160
      ],
      "parameters": {
        "height": 560,
        "content": "## Backup Initiation: \n\nTriggers manually or weekly to start the process "
      },
      "typeVersion": 1
    },
    {
      "id": "742d27cd-19e4-46d5-bffb-0bac0d101a58",
      "name": "付箋1",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -630,
        -265
      ],
      "parameters": {
        "color": 3,
        "width": 380,
        "height": 560,
        "content": "## Workflow Retrieval & Prep: \n\nFetches workflows and prepares metadata"
      },
      "typeVersion": 1
    },
    {
      "id": "8c5e0911-391d-44ca-871b-8d6e20e65939",
      "name": "付箋2",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -230,
        -265
      ],
      "parameters": {
        "color": 6,
        "width": 1340,
        "height": 560,
        "content": "## Combined Processing, Storage, and Notification: \n\nProcesses and formats workflows, saves them to GitLab with file existence checks and updates user-wise, logs results, and sends a success email."
      },
      "typeVersion": 1
    }
  ],
  "active": false,
  "pinData": {},
  "settings": {
    "executionOrder": "v1"
  },
  "versionId": "53da3fbb-7cb8-467b-bac5-c82a414b0096",
  "connections": {
    "bf9ad468-20ad-412a-aceb-034e06795780": {
      "main": [
        [
          {
            "node": "52424bd4-cbce-44a9-ab17-ddf1a910a5b9",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "dea22b1e-e1b3-4440-b757-ba70339950de": {
      "main": [
        [
          {
            "node": "5447ade3-d338-4341-ac86-36e1c1379f5f",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "419a3294-fe3c-41e8-a863-3b9143c8fbba": {
      "main": [
        [
          {
            "node": "7d67c031-8c4a-409b-9c7e-69775b28abf1",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "cbae944a-2622-4ae7-99c1-56efc56d07cf",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "6662cc05-fe42-4f80-a59a-ba670ed143f2": {
      "main": [
        [
          {
            "node": "08d1c5cc-725b-4c9b-a7e4-55df5cd74a27",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "79975f6a-5aa3-4452-ba09-b489eb8c197e": {
      "main": [
        [
          {
            "node": "6662cc05-fe42-4f80-a59a-ba670ed143f2",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "cbae944a-2622-4ae7-99c1-56efc56d07cf": {
      "main": [
        [
          {
            "node": "bf9ad468-20ad-412a-aceb-034e06795780",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "693af3e9-5e9c-44c6-84a3-9a7c7dcca189",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "7d67c031-8c4a-409b-9c7e-69775b28abf1": {
      "main": [
        [
          {
            "node": "cbae944a-2622-4ae7-99c1-56efc56d07cf",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "08d1c5cc-725b-4c9b-a7e4-55df5cd74a27": {
      "main": [
        [
          {
            "node": "cbae944a-2622-4ae7-99c1-56efc56d07cf",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "2d5d5165-ba45-410c-8c5a-37c142b24cc1": {
      "main": [
        [
          {
            "node": "6662cc05-fe42-4f80-a59a-ba670ed143f2",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "693af3e9-5e9c-44c6-84a3-9a7c7dcca189": {
      "main": [
        [
          {
            "node": "dea22b1e-e1b3-4440-b757-ba70339950de",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "5447ade3-d338-4341-ac86-36e1c1379f5f": {
      "main": [
        [
          {
            "node": "419a3294-fe3c-41e8-a863-3b9143c8fbba",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  }
}
よくある質問

このワークフローの使い方は?

上記のJSON設定コードをコピーし、n8nインスタンスで新しいワークフローを作成して「JSONからインポート」を選択、設定を貼り付けて認証情報を必要に応じて変更してください。

このワークフローはどんな場面に適していますか?

中級 - DevOps

有料ですか?

このワークフローは完全無料です。ただし、ワークフローで使用するサードパーティサービス(OpenAI APIなど)は別途料金が発生する場合があります。

ワークフロー情報
難易度
中級
ノード数15
カテゴリー1
ノードタイプ10
難易度説明

経験者向け、6-15ノードの中程度の複雑さのワークフロー

作成者
Oneclick AI Squad

Oneclick AI Squad

@oneclick-ai

The AI Squad Initiative is a pioneering effort to build, automate and scale AI-powered workflows using n8n.io. Our mission is to help individuals and businesses integrate AI agents seamlessly into their daily operations from automating tasks and enhancing productivity to creating innovative, intelligent solutions. We design modular, reusable AI workflow templates that empower creators, developers and teams to supercharge their automation with minimal effort and maximum impact.

外部リンク
n8n.ioで表示

このワークフローを共有

カテゴリー

カテゴリー: 34