定时自动备份工作流到GitHub
中级
这是一个DevOps领域的自动化工作流,包含 10 个节点。主要使用 If, Merge, Github, HttpRequest, MoveBinaryData 等节点。 定时自动备份工作流到GitHub
前置要求
- •GitHub Personal Access Token
- •可能需要目标 API 的认证凭证
分类
工作流预览
可视化展示节点连接关系,支持缩放和平移
导出工作流
复制以下 JSON 配置到 n8n 导入,即可使用此工作流
{
"meta": {
"instanceId": "40e2ddc17723de14c7d0537f9006dd246a3f4df33df6ca7f746ccb612d5f27b9",
"templateCredsSetupCompleted": true
},
"nodes": [
{
"id": "d413aa8d-5e9e-4d06-a4dc-4806d2cf656f",
"name": "便签7",
"type": "n8n-nodes-base.stickyNote",
"position": [
1168,
-16
],
"parameters": {
"color": 2,
"width": 763,
"height": 316,
"content": "## 每6小时备份一次(可根据需求调整)"
},
"typeVersion": 1
},
{
"id": "b2cc1790-3177-4ddd-bcd1-df8408ad7418",
"name": "移动二进制数据",
"type": "n8n-nodes-base.moveBinaryData",
"position": [
1712,
64
],
"parameters": {
"mode": "jsonToBinary",
"options": {
"fileName": "=backup",
"useRawData": true
}
},
"typeVersion": 1
},
{
"id": "f2bd8590-ba99-4bff-a01e-f94306382bb3",
"name": "计划触发器",
"type": "n8n-nodes-base.scheduleTrigger",
"position": [
1200,
64
],
"parameters": {
"rule": {
"interval": [
{
"field": "hours",
"hoursInterval": 6
}
]
}
},
"typeVersion": 1.1
},
{
"id": "44e5938e-5ec5-49b9-9b64-1d2f4507750a",
"name": "便签 2",
"type": "n8n-nodes-base.stickyNote",
"position": [
304,
-128
],
"parameters": {
"width": 720,
"height": 1400,
"content": "# 🚀 自动化 n8n 工作流备份到 GitHub(定时间隔)"
},
"typeVersion": 1
},
{
"id": "9a65446c-1088-477d-b45e-892b65a78153",
"name": "编辑文件",
"type": "n8n-nodes-base.github",
"onError": "continueErrorOutput",
"position": [
1984,
64
],
"webhookId": "32a29392-11c6-402e-9a15-2d7726d3fade",
"parameters": {
"owner": {
"__rl": true,
"mode": "name",
"value": "github-profile-name"
},
"filePath": "backup.json",
"resource": "file",
"operation": "edit",
"binaryData": true,
"repository": {
"__rl": true,
"mode": "list",
"value": "n8n_backup",
"cachedResultUrl": "https://github.com/akashkankariya/n8n_backup",
"cachedResultName": "n8n_backup"
},
"commitMessage": "=n8n_backup_{{ $now.format('yyyy-MM-dd hh') }}"
},
"credentials": {
"githubApi": {
"id": "jxsix3PrSX5TsSW1",
"name": "GitHub Account "
}
},
"typeVersion": 1.1
},
{
"id": "95b1d46c-6641-4b6f-805e-9847ec837878",
"name": "获取所有工作流",
"type": "n8n-nodes-base.httpRequest",
"position": [
1472,
64
],
"parameters": {
"url": "https://your-n8n-instance.com/rest/workflows?limit=9999",
"options": {},
"sendHeaders": true,
"headerParameters": {
"parameters": [
{
"name": "accept",
"value": "application/json"
},
{
"name": "X-N8N-API-KEY",
"value": "<n8n-api-key>"
}
]
}
},
"typeVersion": 4.2
},
{
"id": "528b75d1-0c3a-4e42-bbcb-555f85d151ab",
"name": "创建文件",
"type": "n8n-nodes-base.github",
"position": [
2784,
128
],
"webhookId": "177f801e-da88-46aa-804c-1e365cc1f5aa",
"parameters": {
"owner": {
"__rl": true,
"mode": "name",
"value": "github-profile-name"
},
"filePath": "backup.json",
"resource": "file",
"binaryData": true,
"repository": {
"__rl": true,
"mode": "list",
"value": "n8n_backup",
"cachedResultUrl": "https://github.com/akashkankariya/n8n_backup",
"cachedResultName": "n8n_backup"
},
"commitMessage": "=n8n_backup_{{ $now.format('yyyy-MM-dd hh') }}"
},
"credentials": {
"githubApi": {
"id": "jxsix3PrSX5TsSW1",
"name": "GitHub Account "
}
},
"typeVersion": 1.1
},
{
"id": "f56f7667-d3d8-49ec-8c8c-d25a1ed67adc",
"name": "如果文件不存在?",
"type": "n8n-nodes-base.if",
"position": [
2320,
192
],
"parameters": {
"options": {},
"conditions": {
"options": {
"version": 2,
"leftValue": "",
"caseSensitive": true,
"typeValidation": "strict"
},
"combinator": "and",
"conditions": [
{
"id": "dc419c30-f84f-493f-9125-3b60daeb4a4c",
"operator": {
"name": "filter.operator.equals",
"type": "string",
"operation": "equals"
},
"leftValue": "={{ $json.error }}",
"rightValue": "The resource you are requesting could not be found"
}
]
}
},
"typeVersion": 2.2
},
{
"id": "9025fa65-9c6b-4f1e-898c-45679c720129",
"name": "获取先前文件备份",
"type": "n8n-nodes-base.merge",
"position": [
2560,
128
],
"parameters": {
"mode": "combine",
"options": {},
"joinMode": "enrichInput1",
"fieldsToMatchString": "data"
},
"typeVersion": 3.2
},
{
"id": "41c7655b-5b7d-4f3b-8aca-ba56736d2ec6",
"name": "便签",
"type": "n8n-nodes-base.stickyNote",
"position": [
1952,
-16
],
"parameters": {
"color": 3,
"width": 1063,
"height": 356,
"content": "## 检查文件是否存在,否则将根据错误创建新文件"
},
"typeVersion": 1
}
],
"pinData": {},
"connections": {
"Edit a file": {
"main": [
[],
[
{
"node": "If file not exits?",
"type": "main",
"index": 0
}
]
]
},
"Create a file": {
"main": [
[]
]
},
"Move Binary Data": {
"main": [
[
{
"node": "Edit a file",
"type": "main",
"index": 0
},
{
"node": "Get Previous FIle back",
"type": "main",
"index": 0
}
]
]
},
"Schedule Trigger": {
"main": [
[
{
"node": "Get All Workflows",
"type": "main",
"index": 0
}
]
]
},
"Get All Workflows": {
"main": [
[
{
"node": "Move Binary Data",
"type": "main",
"index": 0
}
]
]
},
"If file not exits?": {
"main": [
[
{
"node": "Get Previous FIle back",
"type": "main",
"index": 1
}
]
]
},
"Get Previous FIle back": {
"main": [
[
{
"node": "Create a file",
"type": "main",
"index": 0
}
]
]
}
}
}常见问题
如何使用这个工作流?
复制上方的 JSON 配置代码,在您的 n8n 实例中创建新工作流并选择「从 JSON 导入」,粘贴配置后根据需要修改凭证设置即可。
这个工作流适合什么场景?
中级 - 开发运维
需要付费吗?
本工作流完全免费,您可以直接导入使用。但请注意,工作流中使用的第三方服务(如 OpenAI API)可能需要您自行付费。
相关工作流推荐
自动化n8n工作流备份至GitHub并追踪删除
自动化n8n工作流备份至GitHub并追踪删除
If
N8n
Set
+13
31 节点Marcial Ambriz
开发运维
Typebot 流程与 GitHub 双向同步,使用 Typebot API
Typebot 流程与 GitHub 双向同步,使用 Typebot API
If
Set
Code
+12
31 节点Marcial Ambriz
开发运维
将您的工作流保存到 GitHub 仓库
每日工作流备份至 GitHub 并发送 Slack 通知
If
N8n
Set
+10
18 节点Andrew
开发运维
GitHub 同步仪表板 - V2
具有提交历史和回滚功能的 GitHub 工作流版本控制仪表板
If
N8n
Set
+20
94 节点Eduard
开发运维
n8n更新
使用 Telegram 审批系统自动化 Docker 容器更新
If
Set
Ssh
+6
27 节点Jaber Zare
开发运维
自动化网站正常运行时间监控与邮件警报及GitHub状态页更新
自动化网站正常运行时间监控与邮件警报及GitHub状态页更新
If
Code
Gmail
+6
19 节点Linearloop Team
开发运维
工作流信息
难度等级
中级
节点数量10
分类1
节点类型7
作者
Akash Kankariya
@akash25I'm a developer with 5 years of experience in Python and Node.js. Over the past year, I've been building workflows to streamline operations for my team. I have also developed RAG chatbots, AI agents, and WhatsApp automation. If you need any help with N8N workflows, let's connect over a call and solve it together!
外部链接
在 n8n.io 查看 →
分享此工作流