AutomationFlowsSlack & Telegram › Automated Workflow Backup System with Google Drive, Github & Messaging Alerts

Automated Workflow Backup System with Google Drive, Github & Messaging Alerts

ByKhairul Muhtadin @khmuhtadin on n8n.io

Stop the panic attacks. We've all been there - accidentally deleted a workflow that took hours to build, or worse, corrupted your entire automation setup. This workflow is your safety net.

Event trigger★★★★☆ complexity20 nodesGoogle Driven8nGitHubDiscordTelegram
Slack & Telegram Trigger: Event Nodes: 20 Complexity: ★★★★☆ Added:

This workflow corresponds to n8n.io template #8771 — we link there as the canonical source.

This workflow follows the Google Drive → Telegram recipe pattern — see all workflows that pair these two integrations.

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
{
  "meta": {
    "templateCredsSetupCompleted": true
  },
  "nodes": [
    {
      "id": "d6f2026a-4e1e-4067-b150-8a8cd5b6726d",
      "name": "Manual Trigger",
      "type": "n8n-nodes-base.manualTrigger",
      "position": [
        -2016,
        576
      ],
      "parameters": {},
      "typeVersion": 1
    },
    {
      "id": "85bccad1-b418-479b-95e3-b59d788a1093",
      "name": "Config",
      "type": "n8n-nodes-base.set",
      "position": [
        -1792,
        672
      ],
      "parameters": {
        "options": {},
        "assignments": {
          "assignments": [
            {
              "id": "repo_owner",
              "name": "repo_owner",
              "type": "string",
              "value": "khmuhtadin"
            },
            {
              "id": "repo_name",
              "name": "repo_name",
              "type": "string",
              "value": "n8n-backup"
            },
            {
              "id": "repo_path",
              "name": "repo_path",
              "type": "string",
              "value": "n8n-backup/"
            },
            {
              "id": "gdrive_folder_id",
              "name": "gdrive_folder_id",
              "type": "string",
              "value": "124XMTeN20Huad4vYkTsiGBwildi4Ea9x"
            },
            {
              "id": "backup_timestamp",
              "name": "backup_timestamp",
              "type": "string",
              "value": "={{ $now.format('yyyy-MM-dd_HH-mm-ss') }}"
            },
            {
              "id": "backup_folder_name",
              "name": "backup_folder_name",
              "type": "string",
              "value": "=wfBackup - {{ $now.format('yyyy-MM-dd_HH-mm-ss') }}"
            },
            {
              "id": "a27de573-1591-4afa-97e5-e38d7b4e9839",
              "name": "telegram_chat_id",
              "type": "number",
              "value": 621412350
            }
          ]
        }
      },
      "typeVersion": 3.4
    },
    {
      "id": "5612fac5-9a76-4f04-a1ab-ca7b36d65742",
      "name": "Create GDrive Folder",
      "type": "n8n-nodes-base.googleDrive",
      "position": [
        -1568,
        672
      ],
      "parameters": {
        "name": "={{ $json.backup_folder_name }}",
        "driveId": {
          "__rl": true,
          "mode": "list",
          "value": "My Drive"
        },
        "options": {},
        "folderId": {
          "__rl": true,
          "mode": "id",
          "value": "={{ $json.gdrive_folder_id }}"
        },
        "resource": "folder"
      },
      "credentials": {
        "googleDriveOAuth2Api": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 3
    },
    {
      "id": "ba92f30e-c74b-4902-9406-d1e47410b8a3",
      "name": "Get All Workflows",
      "type": "n8n-nodes-base.n8n",
      "position": [
        -1344,
        672
      ],
      "parameters": {
        "filters": {},
        "requestOptions": {}
      },
      "credentials": {
        "n8nApi": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 1
    },
    {
      "id": "77790a4b-8144-47c2-9016-a421b9b7d4a1",
      "name": "Loop Over Workflows",
      "type": "n8n-nodes-base.splitInBatches",
      "position": [
        -1120,
        672
      ],
      "parameters": {
        "options": {}
      },
      "typeVersion": 3
    },
    {
      "id": "e93f44ca-c46c-4af8-b291-4beea32ce7ce",
      "name": "Convert to JSON File",
      "type": "n8n-nodes-base.convertToFile",
      "position": [
        -896,
        288
      ],
      "parameters": {
        "options": {
          "format": true,
          "fileName": "={{ $json.name }}.json"
        },
        "operation": "toJson"
      },
      "typeVersion": 1.1
    },
    {
      "id": "c4362690-ceb3-4c7b-aefd-96a917be43c3",
      "name": "Prepare GitHub Data",
      "type": "n8n-nodes-base.code",
      "position": [
        -672,
        384
      ],
      "parameters": {
        "jsCode": "// Get workflow data from the Loop Over Workflows node\nconst workflow = $('Loop Over Workflows').item.json;\nconst config = $('Config').first().json;\n\n// Prepare GitHub path using workflow name instead of ID\nconst date = new Date();\nconst year = date.getFullYear();\nconst month = String(date.getMonth() + 1).padStart(2, '0');\n\n// Sanitize workflow name for use as filename\n// Remove special characters and replace spaces with underscores\nconst sanitizedName = workflow.name\n  .replace(/[^a-zA-Z0-9\\s-_]/g, '') // Remove special characters except spaces, hyphens, underscores\n  .replace(/\\s+/g, '_')              // Replace spaces with underscores\n  .replace(/_+/g, '_')               // Remove multiple underscores\n  .trim();                           // Remove leading/trailing spaces\n\n// Create the GitHub path with sanitized name\nconst githubPath = `${config.repo_path}${year}/${month}/${sanitizedName}.json`;\n\n// Order JSON keys for consistency\nconst orderJsonKeys = (jsonObj) => {\n  const ordered = {};\n  Object.keys(jsonObj).sort().forEach(key => {\n    ordered[key] = jsonObj[key];\n  });\n  return ordered;\n};\n\n// Prepare workflow data\nconst orderedWorkflow = orderJsonKeys(workflow);\nconst workflowJson = JSON.stringify(orderedWorkflow, null, 2);\n\n// Return both the original data and GitHub-specific data\nreturn {\n  ...workflow,\n  github_path: githubPath,\n  workflow_json: workflowJson,\n  year: year,\n  month: month,\n  sanitized_name: sanitizedName\n};"
      },
      "typeVersion": 2
    },
    {
      "id": "24f1655a-bcab-4034-8a55-3bf436c1c32c",
      "name": "Upload to Google Drive",
      "type": "n8n-nodes-base.googleDrive",
      "position": [
        0,
        96
      ],
      "parameters": {
        "name": "={{ $('Loop Over Workflows').item.json.name }}.json",
        "driveId": {
          "__rl": true,
          "mode": "list",
          "value": "My Drive"
        },
        "options": {},
        "folderId": {
          "__rl": true,
          "mode": "id",
          "value": "={{ $('Create GDrive Folder').item.json.id }}"
        }
      },
      "credentials": {
        "googleDriveOAuth2Api": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 3
    },
    {
      "id": "a2380ef2-20ab-4d6d-adab-c2ca130e40ac",
      "name": "Check if File Exists",
      "type": "n8n-nodes-base.github",
      "position": [
        -448,
        384
      ],
      "parameters": {
        "owner": {
          "__rl": true,
          "mode": "expression",
          "value": "={{ $('Config').item.json.repo_owner }}"
        },
        "filePath": "={{ $('Prepare GitHub Data').item.json.github_path }}",
        "resource": "file",
        "operation": "get",
        "repository": {
          "__rl": true,
          "mode": "expression",
          "value": "={{ $('Config').item.json.repo_name }}"
        },
        "authentication": "oAuth2",
        "asBinaryProperty": false,
        "additionalParameters": {}
      },
      "credentials": {
        "githubOAuth2Api": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 1,
      "continueOnFail": true,
      "alwaysOutputData": true
    },
    {
      "id": "87c2b084-0755-4f80-b768-619fc97d03f6",
      "name": "File Exists?",
      "type": "n8n-nodes-base.if",
      "position": [
        -224,
        384
      ],
      "parameters": {
        "options": {},
        "conditions": {
          "options": {
            "leftValue": "",
            "caseSensitive": true,
            "typeValidation": "strict"
          },
          "combinator": "and",
          "conditions": [
            {
              "id": "has-content",
              "operator": {
                "type": "string",
                "operation": "exists"
              },
              "leftValue": "={{ $json.content }}",
              "rightValue": ""
            }
          ]
        }
      },
      "typeVersion": 2
    },
    {
      "id": "683d43dc-3511-4dbb-bdd8-649bd57cd122",
      "name": "Update GitHub File",
      "type": "n8n-nodes-base.github",
      "onError": "continueRegularOutput",
      "position": [
        0,
        288
      ],
      "parameters": {
        "owner": {
          "__rl": true,
          "mode": "expression",
          "value": "={{ $('Config').item.json.repo_owner }}"
        },
        "filePath": "={{ $('Prepare GitHub Data').item.json.github_path }}",
        "resource": "file",
        "operation": "edit",
        "repository": {
          "__rl": true,
          "mode": "expression",
          "value": "={{ $('Config').item.json.repo_name }}"
        },
        "fileContent": "={{ $('Prepare GitHub Data').item.json.workflow_json }}",
        "commitMessage": "=Update: {{ $('Loop Over Workflows').item.json.name }} - {{ $('Config').item.json.backup_timestamp }}",
        "authentication": "oAuth2"
      },
      "credentials": {
        "githubOAuth2Api": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 1,
      "alwaysOutputData": true
    },
    {
      "id": "486829d1-c66d-4b0f-9038-1c8f98a42f65",
      "name": "Create GitHub File",
      "type": "n8n-nodes-base.github",
      "position": [
        0,
        576
      ],
      "parameters": {
        "owner": {
          "__rl": true,
          "mode": "expression",
          "value": "={{ $('Config').item.json.repo_owner }}"
        },
        "filePath": "={{ $('Prepare GitHub Data').item.json.github_path }}",
        "resource": "file",
        "repository": {
          "__rl": true,
          "mode": "expression",
          "value": "={{ $('Config').item.json.repo_name }}"
        },
        "fileContent": "={{ $('Prepare GitHub Data').item.json.workflow_json }}",
        "commitMessage": "=Create: {{ $('Loop Over Workflows').item.json.name }} - {{ $('Config').item.json.backup_timestamp }}",
        "authentication": "oAuth2"
      },
      "credentials": {
        "githubOAuth2Api": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 1
    },
    {
      "id": "7b40e9a2-c182-4b60-84a8-ff468e9a3b24",
      "name": "Merge GitHub Results",
      "type": "n8n-nodes-base.merge",
      "position": [
        224,
        288
      ],
      "parameters": {},
      "typeVersion": 3
    },
    {
      "id": "d478e490-bbbe-4b12-a20a-305ebdafde70",
      "name": "Mark Complete",
      "type": "n8n-nodes-base.set",
      "position": [
        448,
        656
      ],
      "parameters": {
        "options": {},
        "assignments": {
          "assignments": [
            {
              "id": "backup_complete",
              "name": "backup_complete",
              "type": "boolean",
              "value": true
            },
            {
              "id": "workflow_name",
              "name": "workflow_name",
              "type": "string",
              "value": "={{ $('Loop Over Workflows').item.json.name }}"
            },
            {
              "id": "workflow_id",
              "name": "workflow_id",
              "type": "string",
              "value": "={{ $('Loop Over Workflows').item.json.id }}"
            },
            {
              "id": "gdrive_backup",
              "name": "gdrive_backup",
              "type": "boolean",
              "value": true
            },
            {
              "id": "github_backup",
              "name": "github_backup",
              "type": "boolean",
              "value": true
            }
          ]
        }
      },
      "typeVersion": 3.4
    },
    {
      "id": "b0325d2f-51c6-4147-b1fc-e336d26e4a78",
      "name": "Final Summary",
      "type": "n8n-nodes-base.set",
      "position": [
        -896,
        672
      ],
      "parameters": {
        "options": {},
        "assignments": {
          "assignments": [
            {
              "id": "total_workflows",
              "name": "total_workflows",
              "type": "number",
              "value": "={{ $('Get All Workflows').all().length }}"
            },
            {
              "id": "backup_timestamp",
              "name": "backup_timestamp",
              "type": "string",
              "value": "={{ $('Config').first().json.backup_timestamp }}"
            },
            {
              "id": "gdrive_folder",
              "name": "gdrive_folder",
              "type": "string",
              "value": "={{ $('Create GDrive Folder').first().json.name }}"
            },
            {
              "id": "status",
              "name": "status",
              "type": "string",
              "value": "Backup completed successfully"
            }
          ]
        }
      },
      "executeOnce": true,
      "typeVersion": 3.4
    },
    {
      "id": "6aa32c53-f0e5-44a4-9a4c-0a785575f661",
      "name": "Notify: Discord",
      "type": "n8n-nodes-base.discord",
      "position": [
        -672,
        768
      ],
      "parameters": {
        "content": "={{ $json.status }}\n\nTotal workflow: {{ $json.total_workflows }}\nTimestamp: {{ $json.backup_timestamp }}\nDrive Folder: {{ $json.gdrive_folder }}\nRepo Name: {{ $('Config').item.json.repo_name }}",
        "guildId": {
          "__rl": true,
          "mode": "list",
          "value": "924339263372406844",
          "cachedResultUrl": "https://discord.com/channels/924339263372406844",
          "cachedResultName": "Khaisa Studio"
        },
        "options": {},
        "resource": "message",
        "channelId": {
          "__rl": true,
          "mode": "list",
          "value": "1418253548193447936",
          "cachedResultUrl": "https://discord.com/channels/924339263372406844/1418253548193447936",
          "cachedResultName": "monitoring"
        }
      },
      "credentials": {
        "discordBotApi": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 2
    },
    {
      "id": "bde9e6db-95e5-4b36-8ee2-9b3489816c7e",
      "name": "Notify: Telegram",
      "type": "n8n-nodes-base.telegram",
      "position": [
        -672,
        576
      ],
      "parameters": {
        "text": "=<b>\u2705 Backup Status:</b> {{ $json.status }}<br>\n<b>Total Workflows:</b> {{ $json.total_workflows }}<br>\n<b>Timestamp:</b> {{ $json.backup_timestamp }}<br>\n<b>Drive Folder:</b> {{ $json.gdrive_folder }}<br>\n<b>Repo Name:</b> {{ $('Config').item.json.repo_name }}<br><br>\n<i>Your n8n backup has been completed successfully!</i>",
        "chatId": "={{ $('Config').item.json.telegram_chat_id }}",
        "additionalFields": {
          "parse_mode": "HTML",
          "appendAttribution": false
        }
      },
      "credentials": {
        "telegramApi": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 1.2
    },
    {
      "id": "d8638508-4230-4384-8202-7e7a15fd2852",
      "name": "Schedule Every 12 Hours",
      "type": "n8n-nodes-base.scheduleTrigger",
      "position": [
        -2016,
        768
      ],
      "parameters": {
        "rule": {
          "interval": [
            {
              "field": "hours",
              "hoursInterval": 12
            }
          ]
        }
      },
      "typeVersion": 1.2
    },
    {
      "id": "71b29f3d-cf30-4f71-86dc-bee8fc18c2d8",
      "name": "Sticky Note",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -1792,
        896
      ],
      "parameters": {
        "color": 5,
        "width": 448,
        "height": 640,
        "content": "## \ud83d\ude80 n8n Workflow Backup System\n\n### \ud83d\udccb Requirements\n- **n8n API Credentials** - For fetching workflows\n- **Google Drive OAuth2** - For cloud backup storage  \n- **GitHub OAuth2** - For version control backup\n- **Telegram Bot API** (Optional) - For notifications\n- **Discord Bot API** (Optional) - For notifications\n\n### \ud83d\udd17 Resource URLs\n- **n8n API**: [docs.n8n.io/api](https://docs.n8n.io/api/)\n- **Google Drive API**: [console.cloud.google.com](https://console.cloud.google.com/)\n- **GitHub OAuth**: [github.com/settings/developers](https://github.com/settings/developers)\n- **Telegram Bot**: [@BotFather](https://t.me/botfather)\n- **Discord Bot**: [discord.com/developers](https://discord.com/developers/applications)\n\n### \u2728 Features\n- Dual backup (Google Drive + GitHub)\n- Version control with Git history\n- Sanitized filenames (removes special characters)\n- Error handling with fallback\n- Optional notifications on completion\n- Runs automatically twice daily"
      },
      "typeVersion": 1
    },
    {
      "id": "7672fb85-001c-48e5-8181-b48175e45b5a",
      "name": "Sticky Note1",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -1312,
        896
      ],
      "parameters": {
        "color": 5,
        "width": 448,
        "height": 640,
        "content": "## \u2699\ufe0f Configuration\nEdit the **Config** node with your settings:\n- `repo_owner` - Your GitHub username\n- `repo_name` - Repository name for backups\n- `repo_path` - Folder path in repo (e.g., \"n8n-backup/\")\n- `gdrive_folder_id` - Google Drive parent folder ID\n- `telegram_chat_id` - Your Telegram chat ID (optional)\n\n### \ud83d\udcca Workflow Process\n\n1. **Trigger** \u2192 Manual or scheduled every 12 hours\n2. **Setup** \u2192 Creates timestamped backup folder in Google Drive\n3. **Fetch** \u2192 Gets all workflows from n8n instance\n4. **Loop Process** \u2192 For each workflow:\n   - Converts to formatted JSON file\n   - Uploads to Google Drive folder\n   - Checks if file exists on GitHub\n   - Creates new or updates existing GitHub file\n5. **Complete** \u2192 Sends summary notifications to Telegram & Discord\n\n### \ud83d\udcc1 Backup Structure\n- **Google Drive**: `/wfBackup - YYYY-MM-DD_HH-mm-ss/workflow_name.json`\n- **GitHub**: `/n8n-backup/YYYY/MM/workflow_name.json`\n\n"
      },
      "typeVersion": 1
    }
  ],
  "connections": {
    "Config": {
      "main": [
        [
          {
            "node": "Create GDrive Folder",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "File Exists?": {
      "main": [
        [
          {
            "node": "Update GitHub File",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Create GitHub File",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Final Summary": {
      "main": [
        [
          {
            "node": "Notify: Telegram",
            "type": "main",
            "index": 0
          },
          {
            "node": "Notify: Discord",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Mark Complete": {
      "main": [
        [
          {
            "node": "Loop Over Workflows",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Manual Trigger": {
      "main": [
        [
          {
            "node": "Config",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Get All Workflows": {
      "main": [
        [
          {
            "node": "Loop Over Workflows",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Create GitHub File": {
      "main": [
        [
          {
            "node": "Merge GitHub Results",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Update GitHub File": {
      "main": [
        [
          {
            "node": "Merge GitHub Results",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Loop Over Workflows": {
      "main": [
        [
          {
            "node": "Final Summary",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Convert to JSON File",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Prepare GitHub Data": {
      "main": [
        [
          {
            "node": "Check if File Exists",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Check if File Exists": {
      "main": [
        [
          {
            "node": "File Exists?",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Convert to JSON File": {
      "main": [
        [
          {
            "node": "Upload to Google Drive",
            "type": "main",
            "index": 0
          },
          {
            "node": "Prepare GitHub Data",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Create GDrive Folder": {
      "main": [
        [
          {
            "node": "Get All Workflows",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Merge GitHub Results": {
      "main": [
        [
          {
            "node": "Mark Complete",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Upload to Google Drive": {
      "main": [
        [
          {
            "node": "Merge GitHub Results",
            "type": "main",
            "index": 1
          }
        ]
      ]
    },
    "Schedule Every 12 Hours": {
      "main": [
        [
          {
            "node": "Config",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  }
}

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

Stop the panic attacks. We've all been there - accidentally deleted a workflow that took hours to build, or worse, corrupted your entire automation setup. This workflow is your safety net.

Source: https://n8n.io/workflows/8771/ — original creator credit. Request a take-down →

More Slack & Telegram workflows → · Browse all categories →

Related workflows

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

Slack & Telegram

This workflow will backup all of your existed workflows to a single Github repository.

Execute Workflow Trigger, n8n, GitHub +1
Slack & Telegram

Secure your n8n automations with this comprehensive template that automates periodic backups to Telegram for instant access while enabling flexible restores from Google Drive links or direct file uplo

n8n, Telegram, Google Drive +1
Slack & Telegram

✨😃Automated Workflow Backups to Google Drive. Uses manualTrigger, splitInBatches, scheduleTrigger, googleDrive. Event-driven trigger; 22 nodes.

Google Drive, n8n, Telegram
Slack & Telegram

This 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

Google Drive, n8n, Telegram
Slack & Telegram

Effortlessly delete unused or inactive workflows from your n8n instance while automatically backing them up as .json files into your Google Drive. Keep your instance clean, fast, and organized — no mo

Form Trigger, Telegram, Google Drive +1