{
  "createdAt": "2025-06-08T19:59:43.879Z",
  "updatedAt": "2025-06-08T20:09:12.076Z",
  "id": "DKuryiK13AZoiyxS",
  "name": "[bck-fluxos]",
  "active": false,
  "isArchived": false,
  "nodes": [
    {
      "parameters": {
        "options": {}
      },
      "id": "43470f7e-3bc1-470a-af0c-1842cd10fd8d",
      "name": "Set date",
      "type": "n8n-nodes-base.dateTime",
      "typeVersion": 2,
      "position": [
        -1360,
        420
      ]
    },
    {
      "parameters": {
        "operation": "formatDate",
        "date": "={{ $json.currentDate }}",
        "format": "custom",
        "customFormat": "dd-MM-yyyy/H:mm",
        "options": {}
      },
      "id": "baf6edc4-cc62-4b2c-93ff-5643b4fbf3fd",
      "name": "Format date",
      "type": "n8n-nodes-base.dateTime",
      "typeVersion": 2,
      "position": [
        -1160,
        420
      ]
    },
    {
      "parameters": {
        "keepOnlySet": true,
        "values": {
          "string": [
            {
              "name": "commitDate",
              "value": "={{ $json.formattedDate }}"
            }
          ]
        },
        "options": {}
      },
      "id": "8eb8086b-10d9-4d79-a098-c1b0cc00c66a",
      "name": "Set commit date",
      "type": "n8n-nodes-base.set",
      "typeVersion": 2,
      "position": [
        -960,
        420
      ]
    },
    {
      "parameters": {
        "resource": "file",
        "operation": "list",
        "owner": {
          "__rl": true,
          "value": "=https://github.com/suportearmtex",
          "mode": "url"
        },
        "repository": {
          "__rl": true,
          "value": "n8n_bkp",
          "mode": "list",
          "cachedResultName": "n8n_bkp",
          "cachedResultUrl": "https://github.com/suportearmtex/n8n_bkp"
        },
        "filePath": "="
      },
      "id": "ef922572-795b-4261-9784-1f641bcbda6c",
      "name": "List files from repository [GITHUB]",
      "type": "n8n-nodes-base.github",
      "typeVersion": 1,
      "position": [
        -760,
        420
      ],
      "alwaysOutputData": true,
      "credentials": {
        "githubApi": {
          "name": "<your credential>"
        }
      }
    },
    {
      "parameters": {
        "operation": "aggregateItems",
        "fieldsToAggregate": {
          "fieldToAggregate": [
            {
              "fieldToAggregate": "name"
            }
          ]
        },
        "options": {}
      },
      "id": "0b39f721-dc2f-499b-bd4c-5ae241482737",
      "name": "Combine file names [GITHUB]",
      "type": "n8n-nodes-base.itemLists",
      "typeVersion": 2.1,
      "position": [
        -560,
        420
      ]
    },
    {
      "parameters": {
        "filters": {},
        "requestOptions": {}
      },
      "id": "041d64fc-7300-4caf-aff5-78fdbdc098b8",
      "name": "Retrieve workflows [N8N]",
      "type": "n8n-nodes-base.n8n",
      "typeVersion": 1,
      "position": [
        -360,
        420
      ],
      "credentials": {
        "n8nApi": {
          "name": "<your credential>"
        }
      }
    },
    {
      "parameters": {
        "mode": "jsonToBinary",
        "options": {
          "fileName": "={{ $json.name.replace(/\\s+/g, '-').toLowerCase() }}-{{ $json.id }}.json"
        }
      },
      "id": "bcd06ba7-ccd8-4174-9543-2484afc9bc3b",
      "name": "Move JSON to binary",
      "type": "n8n-nodes-base.moveBinaryData",
      "typeVersion": 1,
      "position": [
        -160,
        420
      ]
    },
    {
      "parameters": {
        "batchSize": 1,
        "options": {}
      },
      "id": "ad9f0517-cf80-44f6-92ca-672a05f85107",
      "name": "Split to single items",
      "type": "n8n-nodes-base.splitInBatches",
      "typeVersion": 2,
      "position": [
        80,
        420
      ]
    },
    {
      "parameters": {
        "conditions": {
          "string": [
            {
              "value1": "={{ $node['Combine file names [GITHUB]'].json.name }}",
              "operation": "contains",
              "value2": "={{ $binary.data.fileName }}"
            }
          ]
        }
      },
      "id": "e07119c6-8cdb-42b0-b898-525d6d8ca18a",
      "name": "Check if file exists in repository",
      "type": "n8n-nodes-base.if",
      "typeVersion": 1,
      "position": [
        320,
        340
      ]
    },
    {
      "parameters": {
        "resource": "file",
        "operation": "edit",
        "owner": {
          "__rl": true,
          "value": "https://github.com/suportearmtex",
          "mode": "url"
        },
        "repository": {
          "__rl": true,
          "value": "n8n_bkp",
          "mode": "list",
          "cachedResultName": "n8n_bkp",
          "cachedResultUrl": "https://github.com/armtexIA/n8n_bkp"
        },
        "filePath": "={{ $binary.data.fileName }}",
        "binaryData": true,
        "commitMessage": "=backup-{{ $node['Set commit date'].json.commitDate }}"
      },
      "id": "8ef016dd-f317-41f4-84dd-e4adbbf3c5fa",
      "name": "Update file [GITHUB]",
      "type": "n8n-nodes-base.github",
      "typeVersion": 1,
      "position": [
        540,
        140
      ],
      "credentials": {
        "githubApi": {
          "name": "<your credential>"
        }
      }
    },
    {
      "parameters": {
        "resource": "file",
        "owner": {
          "__rl": true,
          "value": "https://github.com/suportearmtex",
          "mode": "url"
        },
        "repository": {
          "__rl": true,
          "value": "n8n_bkp",
          "mode": "list",
          "cachedResultName": "n8n_bkp",
          "cachedResultUrl": "https://github.com/armtexIA/n8n_bkp"
        },
        "filePath": "={{ $binary.data.fileName }}",
        "binaryData": true,
        "commitMessage": "=backup-{{ $node['Set commit date'].json.commitDate }}"
      },
      "id": "9de43924-65ec-47ba-b9ee-94e04eae07c2",
      "name": "Upload file [GITHUB]",
      "type": "n8n-nodes-base.github",
      "typeVersion": 1,
      "position": [
        540,
        540
      ],
      "credentials": {
        "githubApi": {
          "name": "<your credential>"
        }
      }
    },
    {
      "parameters": {
        "content": "## Setar hora e data\nEsses nodes setam a hora atual no formato `dd-MM-yyyy/H:mm`. Data e hora s\u00e3o utilizadas para dar o commit em atualiza\u00e7\u00f5es no github exemplo: `backup-12-07-2023/14:18`.",
        "height": 339.42690909090965,
        "width": 585.4045090909088
      },
      "id": "38fd6712-d8f6-46e6-80b6-b81e2415521b",
      "name": "Sticky Note1",
      "type": "n8n-nodes-base.stickyNote",
      "typeVersion": 1,
      "position": [
        -1400,
        260
      ]
    },
    {
      "parameters": {
        "content": "## Faz uma lista de arquivos existentes\nRetornar uma lista de arquivos existentes (backups) no reposit\u00f3rio do GitHub. Os dados retornados por esses n\u00f3s s\u00e3o usados pelo n\u00f3 \"IF\" (mais adiante no fluxo de trabalho) para verificar se os arquivos de backup devem ser criados ou atualizados.",
        "height": 366.0444913259516,
        "width": 389.89265454545443
      },
      "id": "cfafdec8-67ff-4a00-b9df-2a2b76a37d5d",
      "name": "Sticky Note2",
      "type": "n8n-nodes-base.stickyNote",
      "typeVersion": 1,
      "position": [
        -800,
        220
      ]
    },
    {
      "parameters": {
        "content": "## Retrieve workflows\nPega todos os workflows no N8N",
        "height": 352.918087417239,
        "width": 384.14708363636373
      },
      "id": "66863453-0b97-4dca-8b8c-d2920a745626",
      "name": "Sticky Note3",
      "type": "n8n-nodes-base.stickyNote",
      "typeVersion": 1,
      "position": [
        -400,
        260
      ]
    },
    {
      "parameters": {
        "content": "## Upload backup\nDivide arquivos JSON em lotes de 1, verifica se foram carregados no reposit\u00f3rio antes. Se sim (verdadeiro), fazer o upload da nova vers\u00e3o do arquivo. Caso contr\u00e1rio (falso), criar o arquivo no reposit\u00f3rio.",
        "height": 731.633426614796,
        "width": 732.2653897437231
      },
      "id": "289e95f9-09d5-41a5-9ff1-36029f3b9871",
      "name": "Sticky Note4",
      "type": "n8n-nodes-base.stickyNote",
      "typeVersion": 1,
      "position": [
        0,
        0
      ]
    },
    {
      "parameters": {
        "rule": {
          "interval": [
            {}
          ]
        }
      },
      "id": "5cccd06f-ba73-4f5c-b09a-4b7337319f81",
      "name": "Schedule Trigger",
      "type": "n8n-nodes-base.scheduleTrigger",
      "typeVersion": 1.2,
      "position": [
        -1540,
        420
      ]
    }
  ],
  "connections": {
    "Set date": {
      "main": [
        [
          {
            "node": "Format date",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Format date": {
      "main": [
        [
          {
            "node": "Set commit date",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Set commit date": {
      "main": [
        [
          {
            "node": "List files from repository [GITHUB]",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "List files from repository [GITHUB]": {
      "main": [
        [
          {
            "node": "Combine file names [GITHUB]",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Combine file names [GITHUB]": {
      "main": [
        [
          {
            "node": "Retrieve workflows [N8N]",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Retrieve workflows [N8N]": {
      "main": [
        [
          {
            "node": "Move JSON to binary",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Move JSON to binary": {
      "main": [
        [
          {
            "node": "Split to single items",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Split to single items": {
      "main": [
        [
          {
            "node": "Check if file exists in repository",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Check if file exists in repository": {
      "main": [
        [
          {
            "node": "Update file [GITHUB]",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Upload file [GITHUB]",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Update file [GITHUB]": {
      "main": [
        [
          {
            "node": "Split to single items",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Upload file [GITHUB]": {
      "main": [
        [
          {
            "node": "Split to single items",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Schedule Trigger": {
      "main": [
        [
          {
            "node": "Set date",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  },
  "settings": {
    "executionOrder": "v1"
  },
  "staticData": null,
  "meta": {
    "templateCredsSetupCompleted": true
  },
  "versionId": "b1d850e9-1ece-4022-ae41-625c523d01a3",
  "triggerCount": 0,
  "tags": [
    {
      "createdAt": "2025-06-08T19:46:11.123Z",
      "updatedAt": "2025-06-08T19:46:11.123Z",
      "id": "RS5Enyqjq1ACZGNy",
      "name": "armtexFluxos"
    }
  ]
}