✨😃Googleドライブへの自動ワークフローバックアップ

上級

これはOther分野の自動化ワークフローで、22個のノードを含みます。主にN8n, Set, Code, Limit, Telegramなどのノードを使用。 ✨😃 自動ワークフローをGoogleドライブにバックアップ

前提条件
  • Telegram Bot Token
  • Google Drive API認証情報

カテゴリー

ワークフロープレビュー
ノード接続関係を可視化、ズームとパンをサポート
ワークフローをエクスポート
以下のJSON設定をn8nにインポートして、このワークフローを使用できます
{
  "id": "o4sdVtTrkuZXDATf",
  "meta": {
    "instanceId": "31e69f7f4a77bf465b805824e303232f0227212ae922d12133a0f96ffeab4fef",
    "templateCredsSetupCompleted": true
  },
  "name": "✨😃Automated Workflow Backups to Google Drive",
  "tags": [],
  "nodes": [
    {
      "id": "f3eba5f7-534e-4eaa-ac84-850d51ff2936",
      "name": "「実行」クリック時",
      "type": "n8n-nodes-base.manualTrigger",
      "position": [
        620,
        -140
      ],
      "parameters": {},
      "typeVersion": 1
    },
    {
      "id": "383e4bed-38ec-4b2f-890c-9b0d9cda8e11",
      "name": "アイテムをループ処理",
      "type": "n8n-nodes-base.splitInBatches",
      "position": [
        1140,
        340
      ],
      "parameters": {
        "options": {
          "reset": false
        }
      },
      "typeVersion": 3
    },
    {
      "id": "38c4c909-fa18-4fa3-abf5-6b9bd2d46718",
      "name": "毎日",
      "type": "n8n-nodes-base.scheduleTrigger",
      "position": [
        620,
        80
      ],
      "parameters": {
        "rule": {
          "interval": [
            {}
          ]
        }
      },
      "typeVersion": 1.2
    },
    {
      "id": "67f62b6e-fe37-4638-89ce-9fe1de041282",
      "name": "日時スタンプ付きフォルダ作成",
      "type": "n8n-nodes-base.googleDrive",
      "position": [
        1220,
        -40
      ],
      "parameters": {
        "name": "=n8n-Workflow-Backups-{{ $json.datetime }}",
        "driveId": {
          "__rl": true,
          "mode": "list",
          "value": "My Drive"
        },
        "options": {},
        "folderId": {
          "__rl": true,
          "mode": "list",
          "value": "root",
          "cachedResultName": "/ (Root folder)"
        },
        "resource": "folder"
      },
      "credentials": {
        "googleDriveOAuth2Api": {
          "id": "UhdXGYLTAJbsa0xX",
          "name": "Google Drive account"
        }
      },
      "typeVersion": 3
    },
    {
      "id": "cfbda56a-2d14-4d64-b40d-89961c0cf0f4",
      "name": "日時を取得",
      "type": "n8n-nodes-base.set",
      "position": [
        920,
        -40
      ],
      "parameters": {
        "options": {},
        "assignments": {
          "assignments": [
            {
              "id": "2589e80c-e8c3-4872-bd7a-d3e92f4a6ab7",
              "name": "datetime",
              "type": "string",
              "value": "={{ $now }}"
            }
          ]
        }
      },
      "typeVersion": 3.4
    },
    {
      "id": "93e8097f-9e7d-49ff-9133-4fd8590f7e31",
      "name": "ワークフローを取得",
      "type": "n8n-nodes-base.n8n",
      "position": [
        1520,
        -40
      ],
      "parameters": {
        "filters": {},
        "requestOptions": {}
      },
      "credentials": {
        "n8nApi": {
          "id": "49QOgnBpyVcT7XQF",
          "name": "n8n account"
        }
      },
      "typeVersion": 1
    },
    {
      "id": "d848ce1d-beb7-4e25-82ac-ed0e8f9523e0",
      "name": "200件に制限",
      "type": "n8n-nodes-base.limit",
      "position": [
        1820,
        -40
      ],
      "parameters": {
        "maxItems": 200
      },
      "typeVersion": 1
    },
    {
      "id": "18f61908-97ce-478c-8544-cfedef22a94c",
      "name": "ワークフローをJSONファイルに変換",
      "type": "n8n-nodes-base.convertToFile",
      "position": [
        1400,
        340
      ],
      "parameters": {
        "options": {
          "fileName": "={{ $json.name }}"
        },
        "operation": "toJson"
      },
      "typeVersion": 1.1
    },
    {
      "id": "97690d84-a0cd-4169-83a8-e4f1d189837e",
      "name": "JSONファイルをGoogleドライブフォルダに保存",
      "type": "n8n-nodes-base.googleDrive",
      "position": [
        1600,
        340
      ],
      "parameters": {
        "name": "={{ $binary.data.fileName }}.json",
        "driveId": {
          "__rl": true,
          "mode": "list",
          "value": "My Drive"
        },
        "options": {},
        "folderId": {
          "__rl": true,
          "mode": "id",
          "value": "={{ $('Create Folder with DateTime Stamp').item.json.id }}"
        }
      },
      "credentials": {
        "googleDriveOAuth2Api": {
          "id": "UhdXGYLTAJbsa0xX",
          "name": "Google Drive account"
        }
      },
      "typeVersion": 3
    },
    {
      "id": "452c0ce8-6e1f-41d7-a94c-25c7abbc32ad",
      "name": "1回実行",
      "type": "n8n-nodes-base.noOp",
      "position": [
        980,
        720
      ],
      "parameters": {},
      "executeOnce": true,
      "typeVersion": 1
    },
    {
      "id": "aadc54d7-2458-4b5b-aa65-07aff52626d2",
      "name": "フォルダ名を検索",
      "type": "n8n-nodes-base.googleDrive",
      "position": [
        1180,
        720
      ],
      "parameters": {
        "limit": 10,
        "filter": {
          "whatToSearch": "folders"
        },
        "options": {},
        "resource": "fileFolder",
        "queryString": "n8n-Workflow-Backups"
      },
      "credentials": {
        "googleDriveOAuth2Api": {
          "id": "UhdXGYLTAJbsa0xX",
          "name": "Google Drive account"
        }
      },
      "executeOnce": true,
      "typeVersion": 3
    },
    {
      "id": "fcb210bf-4947-4178-b85a-8425eb72d937",
      "name": "フォルダを削除",
      "type": "n8n-nodes-base.googleDrive",
      "onError": "continueRegularOutput",
      "position": [
        1600,
        720
      ],
      "parameters": {
        "options": {
          "deletePermanently": true
        },
        "resource": "folder",
        "operation": "deleteFolder",
        "folderNoRootId": {
          "__rl": true,
          "mode": "id",
          "value": "={{ $json.id }}"
        }
      },
      "credentials": {
        "googleDriveOAuth2Api": {
          "id": "UhdXGYLTAJbsa0xX",
          "name": "Google Drive account"
        }
      },
      "typeVersion": 3,
      "alwaysOutputData": true
    },
    {
      "id": "ccdc0655-75e9-4c6b-8ebb-76477733289b",
      "name": "完了メッセージ",
      "type": "n8n-nodes-base.telegram",
      "position": [
        960,
        1040
      ],
      "webhookId": "382a3b43-b83f-47b1-a276-67c6b98a441a",
      "parameters": {
        "text": "={{ $now }}\nWorkflows Backup Complete\n{{ $('Create Folder with DateTime Stamp').item.json.name }}\nhttps://drive.google.com/drive/folders/{{ $('Create Folder with DateTime Stamp').item.json.id }}",
        "chatId": "={{ $env.TELEGRAM_CHAT_ID }}",
        "additionalFields": {
          "parse_mode": "HTML",
          "appendAttribution": false
        }
      },
      "credentials": {
        "telegramApi": {
          "id": "pAIFhguJlkO3c7aQ",
          "name": "Telegram account"
        }
      },
      "typeVersion": 1.2
    },
    {
      "id": "972b4921-803f-4510-9894-9acd2713816a",
      "name": "付箋",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        1020,
        220
      ],
      "parameters": {
        "color": 5,
        "width": 800,
        "height": 360,
        "content": "## Save Workflows to Google Drive"
      },
      "typeVersion": 1
    },
    {
      "id": "254d12e9-0ca6-4953-b375-66a883b44d41",
      "name": "付箋1",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        840,
        620
      ],
      "parameters": {
        "color": 3,
        "width": 980,
        "height": 300,
        "content": "## Keep Most Recent 7 Folders (Days) and Delete Others"
      },
      "typeVersion": 1
    },
    {
      "id": "a1f25512-16d1-45e9-8b18-706288543e03",
      "name": "付箋2",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        840,
        960
      ],
      "parameters": {
        "width": 340,
        "height": 260,
        "content": "## Notify User via Telegram"
      },
      "typeVersion": 1
    },
    {
      "id": "36182be7-f575-4f28-8d63-39802b8428ba",
      "name": "削除対象フォルダを検索",
      "type": "n8n-nodes-base.code",
      "position": [
        1400,
        720
      ],
      "parameters": {
        "jsCode": "// Get all input items and sort by name in descending order\nconst sortedItems = $input.all().sort((a, b) => {\n  if (!a.name || !b.name) return 0;\n  return b.name.localeCompare(a.name);\n});\n\n// Get items older than 7 days\nconst olderItems = sortedItems.slice(7);\n\nreturn olderItems\n\n"
      },
      "typeVersion": 2
    },
    {
      "id": "3a31ee24-3d6c-4340-9c5e-bb1c1cce6151",
      "name": "付箋3",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        1740,
        -160
      ],
      "parameters": {
        "width": 260,
        "height": 340,
        "content": "## Limit for Debugging\nRemove this once you have it up and running"
      },
      "typeVersion": 1
    },
    {
      "id": "df815c43-f6f9-44b8-9503-6a8d0167b844",
      "name": "付箋4",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        1440,
        -160
      ],
      "parameters": {
        "width": 260,
        "height": 340,
        "content": "## Get All Workflows\n"
      },
      "typeVersion": 1
    },
    {
      "id": "c0433a5f-7f6c-4af4-bbbb-ca914aeef33f",
      "name": "付箋5",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        1140,
        -160
      ],
      "parameters": {
        "width": 260,
        "height": 340,
        "content": "## Create NEW Google Folder\n"
      },
      "typeVersion": 1
    },
    {
      "id": "adba380e-16c2-4647-a701-9d5cec1baa0f",
      "name": "付箋6",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        840,
        -160
      ],
      "parameters": {
        "width": 260,
        "height": 340,
        "content": "## Get DateTime Stamp\n"
      },
      "typeVersion": 1
    },
    {
      "id": "4041f4fb-2b51-48e7-af55-b7351a52e4ea",
      "name": "付箋7",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -160,
        -160
      ],
      "parameters": {
        "color": 7,
        "width": 700,
        "height": 1480,
        "content": "# ✨😃 Automated Workflow Backups to Google Drive\n\nThis workflow automates the process of backing up your n8n workflows to Google Drive daily. It creates timestamped folders, saves workflows as JSON files, and manages old backups by retaining only the most recent seven days of data. Notifications are sent via Telegram to keep you informed of the backup status.\n\n## How It Works\n\n### Backup Creation Process 🗂️\n- **Triggering Backups**: The workflow starts with either a manual trigger or a scheduled trigger that runs daily.\n- **Folder Creation**: Creates a new folder in Google Drive with a timestamped name (e.g., `n8n-Workflow-Backups-YYYY-MM-DD`).\n- **Workflow Retrieval**: Fetches all workflows from your n8n instance.\n- **File Conversion**: Converts each workflow into a JSON file for storage.\n- **File Upload**: Saves the JSON files into the newly created Google Drive folder.\n\n### Backup Management 🔄\n- **Folder Search**: Searches for existing backup folders in Google Drive with names matching `n8n-Workflow-Backups`.\n- **Retention Policy**: Identifies folders older than seven days using a custom JavaScript function and deletes them permanently to free up space.\n\n### Notifications 📲\n- **Telegram Alerts**: Sends a message via Telegram once the backup process is complete, including the folder name and a link to access it in Google Drive.\n\n## Setup Steps\n\n### API Configuration 🔑\n1. **Google Drive Integration**:\n   - Set up Google Drive OAuth2 credentials in n8n.\n   - Specify the root folder or desired location for backups.\n2. **n8n API Access**:\n   - Configure n8n API credentials to allow fetching workflows.\n3. **Telegram Notifications**:\n   - Add your Telegram bot credentials and chat ID for notification delivery.\n\n### Workflow Customization ⚙️\n1. Define the schedule for automatic backups (e.g., daily at midnight).\n2. Adjust the retention period if you need more or fewer days of backups.\n3. Customize the Telegram message format as needed.\n\n### Testing & Deployment 🚀\n1. Run the workflow manually to verify folder creation and file uploads.\n2. Check that old folders are deleted correctly after seven days.\n3. Confirm Telegram notifications are sent with accurate details.\n\n## Use Case Scenarios\nThis workflow is perfect for teams or individuals who want to ensure their n8n workflows are securely backed up and organized. It is especially useful for:\n- Protecting against accidental data loss.\n- Automating routine administrative tasks.\n\n\nBy combining automated backups, retention management, and real-time notifications, this workflow ensures your n8n workflows are always safe and accessible!\n"
      },
      "typeVersion": 1
    }
  ],
  "active": true,
  "pinData": {},
  "settings": {
    "timezone": "America/Vancouver",
    "callerPolicy": "workflowsFromSameOwner",
    "executionOrder": "v1"
  },
  "versionId": "11ff8d25-bbc5-4681-b292-ac60a00fd7b0",
  "connections": {
    "38c4c909-fa18-4fa3-abf5-6b9bd2d46718": {
      "main": [
        [
          {
            "node": "cfbda56a-2d14-4d64-b40d-89961c0cf0f4",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "452c0ce8-6e1f-41d7-a94c-25c7abbc32ad": {
      "main": [
        [
          {
            "node": "aadc54d7-2458-4b5b-aa65-07aff52626d2",
            "type": "main",
            "index": 0
          },
          {
            "node": "ccdc0655-75e9-4c6b-8ebb-76477733289b",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "cfbda56a-2d14-4d64-b40d-89961c0cf0f4": {
      "main": [
        [
          {
            "node": "67f62b6e-fe37-4638-89ce-9fe1de041282",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "d848ce1d-beb7-4e25-82ac-ed0e8f9523e0": {
      "main": [
        [
          {
            "node": "383e4bed-38ec-4b2f-890c-9b0d9cda8e11",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "93e8097f-9e7d-49ff-9133-4fd8590f7e31": {
      "main": [
        [
          {
            "node": "d848ce1d-beb7-4e25-82ac-ed0e8f9523e0",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "383e4bed-38ec-4b2f-890c-9b0d9cda8e11": {
      "main": [
        [
          {
            "node": "452c0ce8-6e1f-41d7-a94c-25c7abbc32ad",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "18f61908-97ce-478c-8544-cfedef22a94c",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "aadc54d7-2458-4b5b-aa65-07aff52626d2": {
      "main": [
        [
          {
            "node": "36182be7-f575-4f28-8d63-39802b8428ba",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "f3eba5f7-534e-4eaa-ac84-850d51ff2936": {
      "main": [
        [
          {
            "node": "cfbda56a-2d14-4d64-b40d-89961c0cf0f4",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "36182be7-f575-4f28-8d63-39802b8428ba": {
      "main": [
        [
          {
            "node": "fcb210bf-4947-4178-b85a-8425eb72d937",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "18f61908-97ce-478c-8544-cfedef22a94c": {
      "main": [
        [
          {
            "node": "97690d84-a0cd-4169-83a8-e4f1d189837e",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "67f62b6e-fe37-4638-89ce-9fe1de041282": {
      "main": [
        [
          {
            "node": "93e8097f-9e7d-49ff-9133-4fd8590f7e31",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "97690d84-a0cd-4169-83a8-e4f1d189837e": {
      "main": [
        [
          {
            "node": "383e4bed-38ec-4b2f-890c-9b0d9cda8e11",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  }
}
よくある質問

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

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

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

上級 - その他

有料ですか?

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

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

上級者向け、16ノード以上の複雑なワークフロー

作成者
Joseph LePage

Joseph LePage

@joe

As an AI Automation consultant based in Canada, I partner with forward-thinking organizations to implement AI solutions that streamline operations and drive growth.

外部リンク
n8n.ioで表示

このワークフローを共有

カテゴリー

カテゴリー: 34