使用Google Drive、GitHub和消息警报的自动化工作流备份系统
高级
这是一个Content Creation, Multimodal AI领域的自动化工作流,包含 20 个节点。主要使用 If, N8n, Set, Code, Merge 等节点。 使用Google Drive、GitHub和消息警报的自动化工作流备份系统
前置要求
- •GitHub Personal Access Token
- •Discord Bot Token 或 Webhook
- •Telegram Bot Token
- •Google Drive API 凭证
使用的节点 (20)
工作流预览
可视化展示节点连接关系,支持缩放和平移
导出工作流
复制以下 JSON 配置到 n8n 导入,即可使用此工作流
{
"meta": {
"instanceId": "c2650793f644091dc80fb900fe63448ad1f4b774008de9608064d67294f8307c",
"templateCredsSetupCompleted": true
},
"nodes": [
{
"id": "d6f2026a-4e1e-4067-b150-8a8cd5b6726d",
"name": "手动触发器",
"type": "n8n-nodes-base.manualTrigger",
"position": [
-2016,
576
],
"parameters": {},
"typeVersion": 1
},
{
"id": "85bccad1-b418-479b-95e3-b59d788a1093",
"name": "配置",
"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": "创建 GDrive 文件夹",
"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": {
"id": "nTWGelaHlbvHrG66",
"name": "Khaisa Studio"
}
},
"typeVersion": 3
},
{
"id": "ba92f30e-c74b-4902-9406-d1e47410b8a3",
"name": "获取所有工作流",
"type": "n8n-nodes-base.n8n",
"position": [
-1344,
672
],
"parameters": {
"filters": {},
"requestOptions": {}
},
"credentials": {
"n8nApi": {
"id": "pSE0NDiUNmtDaZ5J",
"name": "khmuhtadin"
}
},
"typeVersion": 1
},
{
"id": "77790a4b-8144-47c2-9016-a421b9b7d4a1",
"name": "遍历工作流",
"type": "n8n-nodes-base.splitInBatches",
"position": [
-1120,
672
],
"parameters": {
"options": {}
},
"typeVersion": 3
},
{
"id": "e93f44ca-c46c-4af8-b291-4beea32ce7ce",
"name": "转换为 JSON 文件",
"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": "准备 GitHub 数据",
"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": "上传到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": {
"id": "nTWGelaHlbvHrG66",
"name": "Khaisa Studio"
}
},
"typeVersion": 3
},
{
"id": "a2380ef2-20ab-4d6d-adab-c2ca130e40ac",
"name": "检查文件是否存在",
"type": "n8n-nodes-base.github",
"position": [
-448,
384
],
"webhookId": "8987819b-d306-48c8-bd8d-58eac1610c75",
"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": {
"id": "WlWFMqmgPWeyIthW",
"name": "khmuhtadin"
}
},
"typeVersion": 1,
"continueOnFail": true,
"alwaysOutputData": true
},
{
"id": "87c2b084-0755-4f80-b768-619fc97d03f6",
"name": "文件存在?",
"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": "更新 GitHub 文件",
"type": "n8n-nodes-base.github",
"onError": "continueRegularOutput",
"position": [
0,
288
],
"webhookId": "d3e6f63d-a808-40cf-8f71-6e6b7fb1a4e5",
"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": {
"id": "WlWFMqmgPWeyIthW",
"name": "khmuhtadin"
}
},
"typeVersion": 1,
"alwaysOutputData": true
},
{
"id": "486829d1-c66d-4b0f-9038-1c8f98a42f65",
"name": "创建 GitHub 文件",
"type": "n8n-nodes-base.github",
"position": [
0,
576
],
"webhookId": "15aff88f-3b60-4232-adcd-b1ddbcc22794",
"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": {
"id": "WlWFMqmgPWeyIthW",
"name": "khmuhtadin"
}
},
"typeVersion": 1
},
{
"id": "7b40e9a2-c182-4b60-84a8-ff468e9a3b24",
"name": "合并 GitHub 结果",
"type": "n8n-nodes-base.merge",
"position": [
224,
288
],
"parameters": {},
"typeVersion": 3
},
{
"id": "d478e490-bbbe-4b12-a20a-305ebdafde70",
"name": "标记完成",
"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": "最终总结",
"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": "通知:Discord",
"type": "n8n-nodes-base.discord",
"position": [
-672,
768
],
"webhookId": "cc8e8a13-3f8f-4d81-848d-770fbd16f26d",
"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": {
"id": "dJMKbc7ZDni2mvkT",
"name": "Khaisa-n8n-bot"
}
},
"typeVersion": 2
},
{
"id": "bde9e6db-95e5-4b36-8ee2-9b3489816c7e",
"name": "通知:Telegram",
"type": "n8n-nodes-base.telegram",
"position": [
-672,
576
],
"webhookId": "bb4dfcba-1411-4242-9302-b23a369fc4a7",
"parameters": {
"text": "=<b>✅ 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": {
"id": "wlH3um2hoPAGI8XX",
"name": "Khaisa Dev Bot"
}
},
"typeVersion": 1.2
},
{
"id": "d8638508-4230-4384-8202-7e7a15fd2852",
"name": "每12小时定时执行",
"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": "便签",
"type": "n8n-nodes-base.stickyNote",
"position": [
-1792,
896
],
"parameters": {
"color": 5,
"width": 448,
"height": 640,
"content": "## 🚀 n8n 工作流备份系统"
},
"typeVersion": 1
},
{
"id": "7672fb85-001c-48e5-8181-b48175e45b5a",
"name": "便签1",
"type": "n8n-nodes-base.stickyNote",
"position": [
-1312,
896
],
"parameters": {
"color": 5,
"width": 448,
"height": 640,
"content": "## ⚙️ 配置"
},
"typeVersion": 1
}
],
"pinData": {},
"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
}
]
]
}
}
}常见问题
如何使用这个工作流?
复制上方的 JSON 配置代码,在您的 n8n 实例中创建新工作流并选择「从 JSON 导入」,粘贴配置后根据需要修改凭证设置即可。
这个工作流适合什么场景?
高级 - 内容创作, 多模态 AI
需要付费吗?
本工作流完全免费,您可以直接导入使用。但请注意,工作流中使用的第三方服务(如 OpenAI API)可能需要您自行付费。
相关工作流推荐
AI驱动视频创作与上传至Instagram、TikTok和YouTube
从云端硬盘进行AI驱动视频创作并上传至Instagram、TikTok和YouTube
If
Set
Code
+14
53 节点DevCode Journey
内容创作
WordPress博客自动化专业版(深度研究)v2.1市场
使用GPT-4o、Perplexity AI和多语言支持自动化SEO优化的博客创建
If
Set
Xml
+27
125 节点Daniel Ng
内容创作
LinkedIn和X病毒内容自动引擎
使用AI生成和发布自动创建LinkedIn和X的病毒内容
If
Set
Wait
+26
156 节点Diptamoy Barman
内容创作
WordPress + 社交媒体
基于GPT/Gemini和WordPress的自动化博客创建与多平台发布
If
Set
Switch
+18
44 节点Khairul Muhtadin
内容创作
高级 n8n 工作流与 GitHub 同步
使用 GitHub 的智能变更检测自动化工作流备份
If
N8n
Set
+10
38 节点Maksym Brashenko
开发运维
使用Google Maps、GPT-4和WhatsApp自动化商业合作伙伴拓展
使用Google Maps、GPT-4和WhatsApp自动化商业合作伙伴拓展
If
Set
Code
+23
64 节点Khairul Muhtadin
AI 聊天机器人