Programación automática de copias de seguridad de flujos de trabajo a GitHub cada 4 horas
Este es unDevOpsflujo de automatización del dominio deautomatización que contiene 10 nodos.Utiliza principalmente nodos como If, Merge, Github, HttpRequest, MoveBinaryData. Copia de seguridad programada automática de flujos de trabajo en GitHub
- •Personal Access Token de GitHub
- •Pueden requerirse credenciales de autenticación para la API de destino
Nodos utilizados (10)
Categoría
{
"meta": {
"instanceId": "40e2ddc17723de14c7d0537f9006dd246a3f4df33df6ca7f746ccb612d5f27b9",
"templateCredsSetupCompleted": true
},
"nodes": [
{
"id": "d413aa8d-5e9e-4d06-a4dc-4806d2cf656f",
"name": "Nota adhesiva7",
"type": "n8n-nodes-base.stickyNote",
"position": [
1168,
-16
],
"parameters": {
"color": 2,
"width": 763,
"height": 316,
"content": "## Backup every 6 Hour (can be changed as per requirement) "
},
"typeVersion": 1
},
{
"id": "b2cc1790-3177-4ddd-bcd1-df8408ad7418",
"name": "Move Binary Data",
"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": "Disparador programado",
"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": "Nota adhesiva2",
"type": "n8n-nodes-base.stickyNote",
"position": [
304,
-128
],
"parameters": {
"width": 720,
"height": 1400,
"content": "# 🚀 Automated n8n Workflow Backup to GitHub for schedule Interval\n\nEasily ensure your n8n workflows are never lost! This template automates the process of backing up all your n8n workflows to a GitHub repository every 6 hours. Set it up once and enjoy *worry-free* workflow versioning and disaster recovery! 🔄✨\n\n## 📝 What This Workflow Does\n\n- **Schedules backups**: Triggers the workflow automatically every 6 hours—no manual steps needed. ⏰\n- **Exports all current workflows**: Collects a JSON snapshot of every workflow in your n8n instance. 📦\n- **Pushes backups to GitHub**: Commits each backup file to your specified GitHub repository with a time-stamped commit message for easy tracking. 🗂️🚀\n- **Smart file handling**: Checks if a backup file already exists and creates or updates as needed, keeping your repository clean and organized. 🤖\n\n##⚡️ Why Use This Template?\n\n- **Automate your workflow backups – never miss a backup again!**\n- **Seamless integration with GitHub** for team collaboration, change management, and rollback.\n- **Simple, reliable, and fully customizable** to match your backup intervals and repository setup.\n- **Peace of mind** that your critical automation assets are always protected.\n\n## 📦 How the Template Works: Step-by-step Overview\n\n1. **Scheduled Trigger**: Fires every 6 hours to launch the backup sequence.\n2. **Get All Workflows**: Uses the `HTTP Request` node to fetch all n8n workflows from your instance as JSON data.\n3. **Move Binary Data**: Converts the JSON into a binary format, ready for GitHub storage.\n4. **Edit/Create Backup File**: Attempts to edit (update) an existing backup file in your GitHub repo. If the file does not exist, the workflow will create a new one.\n5. **Conditional Logic**: Checks after each run whether the backup file exists and ensures previous versions can be recovered or merged as needed.\n6. **Repeat**: The process auto-loops every 6 hours—no further intervention required!\n\n## 🔧 How To Set Up On Your Server\n\n1. **Import the template** into your n8n instance.\n2. **Configure your GitHub credentials** in the workflow nodes.\n3. **Update the GitHub repository details** (`owner`, `repository`, and `filePath`) to use your own repo and desired file path.\n4. **Set your n8n API key** and update the API endpoint URL to match your deployment.\n5. **Save and activate** the workflow—now your backups are on autopilot!\n\n## 👨💻 Example Use Cases\n\n- Version control for rapidly changing automation environments.\n- Safeguarding business-critical automation assets.\n- Easy rollback in case of workflow corruption or accidental deletion.\n- Team collaboration through GitHub's pull request and review process.\n\n## 🌟 Pro Tips\n\n- Adjust the backup interval in the `Schedule Trigger` node if you require more/less frequent backups.\n- Use GitHub branch protection rules for enhanced workflow security.\n- Pair this backup workflow with notifications (e.g., Slack or Email) for backup alerts.\n\n**Protect your n8n workflows with automated, reliable, and versioned GitHub backups—set it and forget it!** 🚦🔒"
},
"typeVersion": 1
},
{
"id": "9a65446c-1088-477d-b45e-892b65a78153",
"name": "Edit a file",
"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": "Get All Workflows",
"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": "Create a file",
"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": "If file not exits?",
"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": "Get Previous FIle back",
"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": "Nota adhesiva",
"type": "n8n-nodes-base.stickyNote",
"position": [
1952,
-16
],
"parameters": {
"color": 3,
"width": 1063,
"height": 356,
"content": "## Check if File is present or not else it will create file a new file based on error"
},
"typeVersion": 1
}
],
"pinData": {},
"connections": {
"9a65446c-1088-477d-b45e-892b65a78153": {
"main": [
[],
[
{
"node": "f56f7667-d3d8-49ec-8c8c-d25a1ed67adc",
"type": "main",
"index": 0
}
]
]
},
"528b75d1-0c3a-4e42-bbcb-555f85d151ab": {
"main": [
[]
]
},
"b2cc1790-3177-4ddd-bcd1-df8408ad7418": {
"main": [
[
{
"node": "9a65446c-1088-477d-b45e-892b65a78153",
"type": "main",
"index": 0
},
{
"node": "9025fa65-9c6b-4f1e-898c-45679c720129",
"type": "main",
"index": 0
}
]
]
},
"Schedule Trigger": {
"main": [
[
{
"node": "95b1d46c-6641-4b6f-805e-9847ec837878",
"type": "main",
"index": 0
}
]
]
},
"95b1d46c-6641-4b6f-805e-9847ec837878": {
"main": [
[
{
"node": "b2cc1790-3177-4ddd-bcd1-df8408ad7418",
"type": "main",
"index": 0
}
]
]
},
"f56f7667-d3d8-49ec-8c8c-d25a1ed67adc": {
"main": [
[
{
"node": "9025fa65-9c6b-4f1e-898c-45679c720129",
"type": "main",
"index": 1
}
]
]
},
"9025fa65-9c6b-4f1e-898c-45679c720129": {
"main": [
[
{
"node": "528b75d1-0c3a-4e42-bbcb-555f85d151ab",
"type": "main",
"index": 0
}
]
]
}
}
}¿Cómo usar este flujo de trabajo?
Copie el código de configuración JSON de arriba, cree un nuevo flujo de trabajo en su instancia de n8n y seleccione "Importar desde JSON", pegue la configuración y luego modifique la configuración de credenciales según sea necesario.
¿En qué escenarios es adecuado este flujo de trabajo?
Intermedio - DevOps
¿Es de pago?
Este flujo de trabajo es completamente gratuito, puede importarlo y usarlo directamente. Sin embargo, tenga en cuenta que los servicios de terceros utilizados en el flujo de trabajo (como la API de OpenAI) pueden requerir un pago por su cuenta.
Flujos de trabajo relacionados recomendados
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!
Compartir este flujo de trabajo