From 35cf9edd3f5486f99436d30214e47343e9597ce4 Mon Sep 17 00:00:00 2001 From: Gabriel Augusto Date: Mon, 30 Sep 2024 15:49:01 -0300 Subject: [PATCH] Arquivos video Backup Github --- Backup Github/Backup_Youtube.json | 447 ++++++++++++++++++++++++++++++ Backup Github/README.md | 21 ++ Backup Github/Restore_Backup.json | 190 +++++++++++++ 3 files changed, 658 insertions(+) create mode 100644 Backup Github/Backup_Youtube.json create mode 100644 Backup Github/README.md create mode 100644 Backup Github/Restore_Backup.json diff --git a/Backup Github/Backup_Youtube.json b/Backup Github/Backup_Youtube.json new file mode 100644 index 0000000..a1d0870 --- /dev/null +++ b/Backup Github/Backup_Youtube.json @@ -0,0 +1,447 @@ +{ + "name": "Backup Youtube", + "nodes": [ + { + "parameters": { + "assignments": { + "assignments": [ + { + "id": "61df5ffb-7587-4ec0-a4ef-5d03168857c5", + "name": "owner", + "value": "gabriel-g2n", + "type": "string" + }, + { + "id": "167893e5-9de8-4273-9fc3-3f2da550ebf7", + "name": "repository", + "value": "n8n-backup-youtube", + "type": "string" + } + ] + }, + "options": {} + }, + "id": "6dceb5a2-5b6a-4c1e-8972-ab99e89bff25", + "name": "Infos Basicas", + "type": "n8n-nodes-base.set", + "typeVersion": 3.4, + "position": [ + 1060, + 420 + ] + }, + { + "parameters": { + "mode": "raw", + "jsonOutput": "={{ $json.data }}", + "options": {} + }, + "id": "25f06400-d90d-4910-9e86-16eeb8587875", + "name": "Workflow", + "type": "n8n-nodes-base.set", + "typeVersion": 3.4, + "position": [ + 2300, + 800 + ] + }, + { + "parameters": { + "operation": "toJson", + "mode": "each", + "options": { + "format": true, + "fileName": "={{ $json.id }}.json" + } + }, + "id": "9947b777-67b0-414f-9070-9615e8467cbf", + "name": "Convert to File", + "type": "n8n-nodes-base.convertToFile", + "typeVersion": 1.1, + "position": [ + 2500, + 800 + ] + }, + { + "parameters": { + "authentication": "oAuth2", + "resource": "file", + "operation": "get", + "owner": { + "__rl": true, + "value": "={{ $('Infos Basicas').item.json.owner }}", + "mode": "name" + }, + "repository": { + "__rl": true, + "value": "={{ $('Infos Basicas').item.json.repository }}", + "mode": "name" + }, + "filePath": "=cliente-x/{{ $json.id }}.json", + "additionalParameters": {} + }, + "id": "c3986913-970e-492e-a097-c99356f73aac", + "name": "GitHub", + "type": "n8n-nodes-base.github", + "typeVersion": 1, + "position": [ + 1600, + 280 + ], + "alwaysOutputData": true, + "credentials": { + "githubOAuth2Api": { + "id": "cK5zPCTIu4VbpDUE", + "name": "GitHub account 2" + } + }, + "onError": "continueRegularOutput" + }, + { + "parameters": { + "operation": "fromJson", + "options": {} + }, + "id": "9fced7bb-29b4-4586-9cf5-dfee80ed44f1", + "name": "Extract from File", + "type": "n8n-nodes-base.extractFromFile", + "typeVersion": 1, + "position": [ + 1820, + 280 + ] + }, + { + "parameters": { + "assignments": { + "assignments": [ + { + "id": "d55c571b-e214-48c5-9516-b16c71f5419e", + "name": "data", + "value": "={{ $json }}", + "type": "object" + } + ] + }, + "options": {} + }, + "id": "72bd9205-f5e2-452f-bc3d-6d449136d5e5", + "name": "Workflow dados", + "type": "n8n-nodes-base.set", + "typeVersion": 3.4, + "position": [ + 1600, + 620 + ] + }, + { + "parameters": { + "filters": {}, + "requestOptions": {} + }, + "id": "807b3002-72e1-4195-a442-43671cb97a7b", + "name": "Obter todos", + "type": "n8n-nodes-base.n8n", + "typeVersion": 1, + "position": [ + 1280, + 420 + ], + "credentials": { + "n8nApi": { + "id": "0Owhw6MuBsjylAFE", + "name": "n8n account" + } + } + }, + { + "parameters": { + "mergeByFields": { + "values": [ + { + "field1": "data.id", + "field2": "data.id" + } + ] + }, + "resolve": "preferInput2", + "options": {} + }, + "id": "8f504a84-3c54-4575-a133-31ae32f0ebd7", + "name": "Compare Datasets", + "type": "n8n-nodes-base.compareDatasets", + "typeVersion": 2.3, + "position": [ + 2060, + 480 + ] + }, + { + "parameters": { + "authentication": "oAuth2", + "resource": "file", + "owner": { + "__rl": true, + "value": "={{ $('Infos Basicas').first().json.owner }}", + "mode": "name" + }, + "repository": { + "__rl": true, + "value": "={{ $('Infos Basicas').first().json.repository }}", + "mode": "name" + }, + "filePath": "=cliente-x/{{ $('Workflow').item.json.id }}.json", + "binaryData": true, + "commitMessage": "={{ $('Workflow').item.json.name }} {{ $now.toString() }}" + }, + "id": "5592b75e-3f47-47ae-af6f-c93e2a57a22d", + "name": "GitHub Create File", + "type": "n8n-nodes-base.github", + "typeVersion": 1, + "position": [ + 2700, + 800 + ], + "credentials": { + "githubOAuth2Api": { + "id": "cK5zPCTIu4VbpDUE", + "name": "GitHub account 2" + } + } + }, + { + "parameters": { + "rule": { + "interval": [ + {} + ] + } + }, + "id": "e3766688-a3ad-483f-be4a-ead95e1cfe59", + "name": "Schedule Trigger", + "type": "n8n-nodes-base.scheduleTrigger", + "typeVersion": 1.2, + "position": [ + 820, + 420 + ] + }, + { + "parameters": { + "mode": "raw", + "jsonOutput": "={{ $json.data }}", + "options": {} + }, + "id": "a827580c-511f-4bfe-95f8-d9aa3058feb9", + "name": "Workflow1", + "type": "n8n-nodes-base.set", + "typeVersion": 3.4, + "position": [ + 2300, + 600 + ] + }, + { + "parameters": { + "operation": "toJson", + "mode": "each", + "options": { + "format": true, + "fileName": "={{ $json.id }}.json" + } + }, + "id": "91c3505f-33cb-496d-ba89-842e7a460530", + "name": "Convert to File1", + "type": "n8n-nodes-base.convertToFile", + "typeVersion": 1.1, + "position": [ + 2500, + 600 + ] + }, + { + "parameters": { + "authentication": "oAuth2", + "resource": "file", + "operation": "edit", + "owner": { + "__rl": true, + "value": "={{ $('Infos Basicas').first().json.owner }}", + "mode": "name" + }, + "repository": { + "__rl": true, + "value": "={{ $('Infos Basicas').first().json.repository }}", + "mode": "name" + }, + "filePath": "=cliente-x/{{ $('Workflow1').item.json.id }}.json", + "binaryData": true, + "commitMessage": "={{ $('Workflow1').item.json.name }} {{ $now.toString() }}" + }, + "id": "f50364ad-9136-4f2d-9689-977bca7b0689", + "name": "GitHub Edit File", + "type": "n8n-nodes-base.github", + "typeVersion": 1, + "position": [ + 2700, + 600 + ], + "credentials": { + "githubOAuth2Api": { + "id": "cK5zPCTIu4VbpDUE", + "name": "GitHub account 2" + } + } + } + ], + "pinData": {}, + "connections": { + "Infos Basicas": { + "main": [ + [ + { + "node": "Obter todos", + "type": "main", + "index": 0 + } + ] + ] + }, + "Workflow": { + "main": [ + [ + { + "node": "Convert to File", + "type": "main", + "index": 0 + } + ] + ] + }, + "Convert to File": { + "main": [ + [ + { + "node": "GitHub Create File", + "type": "main", + "index": 0 + } + ] + ] + }, + "GitHub": { + "main": [ + [ + { + "node": "Extract from File", + "type": "main", + "index": 0 + } + ] + ] + }, + "Extract from File": { + "main": [ + [ + { + "node": "Compare Datasets", + "type": "main", + "index": 0 + } + ] + ] + }, + "Workflow dados": { + "main": [ + [ + { + "node": "Compare Datasets", + "type": "main", + "index": 1 + } + ] + ] + }, + "Obter todos": { + "main": [ + [ + { + "node": "GitHub", + "type": "main", + "index": 0 + }, + { + "node": "Workflow dados", + "type": "main", + "index": 0 + } + ] + ] + }, + "Compare Datasets": { + "main": [ + [], + [], + [ + { + "node": "Workflow1", + "type": "main", + "index": 0 + } + ], + [ + { + "node": "Workflow", + "type": "main", + "index": 0 + } + ] + ] + }, + "Schedule Trigger": { + "main": [ + [ + { + "node": "Infos Basicas", + "type": "main", + "index": 0 + } + ] + ] + }, + "Workflow1": { + "main": [ + [ + { + "node": "Convert to File1", + "type": "main", + "index": 0 + } + ] + ] + }, + "Convert to File1": { + "main": [ + [ + { + "node": "GitHub Edit File", + "type": "main", + "index": 0 + } + ] + ] + } + }, + "active": true, + "settings": { + "executionOrder": "v1" + }, + "versionId": "5731763a-01bd-4ef9-a462-a148c354c7d6", + "meta": { + "templateCredsSetupCompleted": true, + "instanceId": "2ad20c637f548d7b1e09cbae0383c6644aca87b4f0fe8deda2de937f77c2be79" + }, + "id": "FIKX6Vl9TSbIVvsy", + "tags": [] +} \ No newline at end of file diff --git a/Backup Github/README.md b/Backup Github/README.md new file mode 100644 index 0000000..a992a2e --- /dev/null +++ b/Backup Github/README.md @@ -0,0 +1,21 @@ +# Backup Automático de Workflows do n8n para GitHub + +Este repositório contém o fluxo do **n8n** que automatiza o processo de backup dos seus workflows diretamente para o **GitHub**. Esse processo garante que você tenha um histórico de versões de cada workflow, permitindo restaurá-los facilmente em caso de perda ou corrompimento do servidor. + +## Descrição + +No vídeo [Como Fazer Backup de Workflows N8N no GitHub de Forma Segura e Automática](https://www.youtube.com/watch?v=czdE1XyOrQo), mostramos a importância de fazer backups regulares dos workflows do n8n e como configurá-los para serem enviados automaticamente ao GitHub, sem a necessidade de fazer upload manual. A solução permite que o backup seja feito de forma programada, armazenando cada versão em um repositório GitHub. + +### O que você vai aprender: +- **Como criar backups automáticos** dos workflows do n8n. +- **Configurar o GitHub como repositório** para armazenar seus backups de forma segura e organizada. +- **Controlar versões** dos seus workflows para restaurar qualquer versão anterior de um fluxo. + +### Link mencionado: +- 🔗 [Repositório de Workflows no GitHub](https://github.com/gabriel-g2n/workflows) + +## Como usar este repositório + +1. **Clonar o Repositório** + + Baixe o Json do fluxo escolhido e importe no N8N. \ No newline at end of file diff --git a/Backup Github/Restore_Backup.json b/Backup Github/Restore_Backup.json new file mode 100644 index 0000000..a09063c --- /dev/null +++ b/Backup Github/Restore_Backup.json @@ -0,0 +1,190 @@ +{ + "name": "Restore Backup", + "nodes": [ + { + "parameters": {}, + "id": "569b9057-5cb8-43f6-a778-93fd24e70be2", + "name": "When clicking ‘Test workflow’", + "type": "n8n-nodes-base.manualTrigger", + "typeVersion": 1, + "position": [ + 820, + 380 + ] + }, + { + "parameters": { + "authentication": "oAuth2", + "resource": "file", + "operation": "get", + "owner": { + "__rl": true, + "value": "={{ $json.dono }}", + "mode": "name" + }, + "repository": { + "__rl": true, + "value": "={{ $json.repositorio }}", + "mode": "name" + }, + "filePath": "={{ $json.arquirvo }}", + "additionalParameters": { + "reference": "={{ $json.versao }}" + } + }, + "id": "21def428-1ba2-4d66-aaff-839422f8478d", + "name": "GitHub", + "type": "n8n-nodes-base.github", + "typeVersion": 1, + "position": [ + 1260, + 380 + ], + "credentials": { + "githubOAuth2Api": { + "id": "cK5zPCTIu4VbpDUE", + "name": "GitHub account 2" + } + } + }, + { + "parameters": { + "operation": "fromJson", + "options": {} + }, + "id": "257d9d98-46f8-4a43-baee-cb9949f1a53d", + "name": "Extract from File", + "type": "n8n-nodes-base.extractFromFile", + "typeVersion": 1, + "position": [ + 1480, + 380 + ] + }, + { + "parameters": { + "operation": "update", + "workflowId": { + "__rl": true, + "value": "={{ $json.data.id }}", + "mode": "id" + }, + "workflowObject": "={{ JSON.stringify($json.data) }}", + "requestOptions": {} + }, + "id": "1ef3b415-486a-4cfb-b849-c5df349df99d", + "name": "n8n", + "type": "n8n-nodes-base.n8n", + "typeVersion": 1, + "position": [ + 1700, + 380 + ], + "credentials": { + "n8nApi": { + "id": "0Owhw6MuBsjylAFE", + "name": "n8n account" + } + } + }, + { + "parameters": { + "assignments": { + "assignments": [ + { + "id": "200d0b65-a68f-47d6-b6ea-1df49f417ecc", + "name": "arquirvo", + "value": "cliente-x/0m5NWU4NvuUfff2I.json", + "type": "string" + }, + { + "id": "0cf92acd-3e55-4618-881e-97c2c60db6bc", + "name": "dono", + "value": "gabriel-g2n", + "type": "string" + }, + { + "id": "257bb5a0-e186-44a5-a21a-fcd751f9f567", + "name": "repositorio", + "value": "n8n-backup-youtube", + "type": "string" + }, + { + "id": "5ceff380-1ffb-4e87-afff-b296d8a92637", + "name": "versao", + "value": "", + "type": "string" + } + ] + }, + "options": {} + }, + "id": "0291a08f-8d04-4b22-b249-72cc95df747f", + "name": "Info Basica", + "type": "n8n-nodes-base.set", + "typeVersion": 3.4, + "position": [ + 1040, + 380 + ] + } + ], + "pinData": {}, + "connections": { + "When clicking ‘Test workflow’": { + "main": [ + [ + { + "node": "Info Basica", + "type": "main", + "index": 0 + } + ] + ] + }, + "GitHub": { + "main": [ + [ + { + "node": "Extract from File", + "type": "main", + "index": 0 + } + ] + ] + }, + "Extract from File": { + "main": [ + [ + { + "node": "n8n", + "type": "main", + "index": 0 + } + ] + ] + }, + "Info Basica": { + "main": [ + [ + { + "node": "GitHub", + "type": "main", + "index": 0 + } + ] + ] + } + }, + "active": false, + "settings": { + "executionOrder": "v1" + }, + "versionId": "04182085-e8f2-4b52-b452-264216cd5519", + "meta": { + "templateCredsSetupCompleted": true, + "instanceId": "2ad20c637f548d7b1e09cbae0383c6644aca87b4f0fe8deda2de937f77c2be79" + }, + "id": "BahQJuBUAZcTktct", + "tags": [] +} \ No newline at end of file