{
  "nodes": [
    {
      "parameters": {
        "authentication": "webhook",
        "content": "n8n 備份成功！",
        "options": {}
      },
      "type": "n8n-nodes-base.discord",
      "typeVersion": 2,
      "position": [1720, 0],
      "id": "ef5ce15e-82f0-4a02-8c1f-d998cc459363",
      "name": "通知",
      "webhookId": "35e8f84e-39cb-477f-a8bd-b7ceb6c6ee3f",
      "notesInFlow": true,
      "retryOnFail": true,
      "executeOnce": true,
      "credentials": {
        "discordWebhookApi": {
          "id": "f922R8ql3dYRwPBN",
          "name": "Discord #boom"
        }
      }
    },
    {
      "parameters": {},
      "type": "n8n-nodes-base.merge",
      "typeVersion": 3,
      "position": [1440, 0],
      "id": "ee4738c5-5815-4474-8ab8-f7796287eead",
      "name": "合併流程",
      "notesInFlow": true
    },
    {
      "parameters": {
        "command": "rm -rf /tmp/workflows /tmp/credentials"
      },
      "type": "n8n-nodes-base.executeCommand",
      "typeVersion": 1,
      "position": [1580, 0],
      "id": "78b017e7-c4f0-4b49-9a5f-739877e31e14",
      "name": "刪除匯出資料",
      "notesInFlow": true
    },
    {
      "parameters": {
        "command": "n8n export:workflow --backup --output=/tmp/workflows"
      },
      "type": "n8n-nodes-base.executeCommand",
      "typeVersion": 1,
      "position": [300, -140],
      "id": "992abf03-058e-4ea8-be6e-4538caecc306",
      "name": "匯出工作流程"
    },
    {
      "parameters": {
        "fileSelector": "/tmp/workflows/*.json",
        "options": {}
      },
      "type": "n8n-nodes-base.readWriteFile",
      "typeVersion": 1,
      "position": [700, -160],
      "id": "d6ec3904-95a3-4e1d-9751-ddf98cd859fb",
      "name": "讀取工作流程備份檔",
      "retryOnFail": true,
      "notesInFlow": true
    },
    {
      "parameters": {
        "operation": "deleteFile",
        "fileId": {
          "__rl": true,
          "value": "={{ $json.id }}",
          "mode": "id"
        },
        "options": {
          "deletePermanently": true
        }
      },
      "type": "n8n-nodes-base.googleDrive",
      "typeVersion": 3,
      "position": [1060, -260],
      "id": "911d1e51-36d8-43bd-beb5-5d64b1dccd53",
      "name": "刪除舊備份檔",
      "retryOnFail": true,
      "alwaysOutputData": false,
      "notesInFlow": true,
      "credentials": {
        "googleDriveOAuth2Api": {
          "id": "4rBIaJA0fKbd6mpT",
          "name": "Google Drive (n8n)"
        }
      }
    },
    {
      "parameters": {
        "command": "n8n export:credentials --backup --decrypted --output=/tmp/credentials"
      },
      "type": "n8n-nodes-base.executeCommand",
      "typeVersion": 1,
      "position": [320, 80],
      "id": "2704d431-0afd-49f4-b0f4-895de13ac3d6",
      "name": "匯出金鑰"
    },
    {
      "parameters": {
        "fileSelector": "/tmp/credentials/*.json",
        "options": {}
      },
      "type": "n8n-nodes-base.readWriteFile",
      "typeVersion": 1,
      "position": [700, 40],
      "id": "dbd5f99b-164b-46e1-88cf-f4622e3eb94f",
      "name": "讀取金鑰備份檔",
      "retryOnFail": true,
      "notesInFlow": true
    },
    {
      "parameters": {
        "conditions": {
          "options": {
            "caseSensitive": true,
            "leftValue": "",
            "typeValidation": "strict",
            "version": 2
          },
          "conditions": [
            {
              "id": "d45543b3-e96b-49d2-954c-83fee6fae3ec",
              "leftValue": "={{ $json.exitCode }}",
              "rightValue": 0,
              "operator": {
                "type": "number",
                "operation": "equals"
              }
            }
          ],
          "combinator": "and"
        },
        "options": {}
      },
      "type": "n8n-nodes-base.if",
      "typeVersion": 2.2,
      "position": [460, -140],
      "id": "b5f9ffde-6f39-40d3-89ec-c385c5ee9bd5",
      "name": "檢查工作流程是否匯出成功"
    },
    {
      "parameters": {
        "conditions": {
          "options": {
            "caseSensitive": true,
            "leftValue": "",
            "typeValidation": "strict",
            "version": 2
          },
          "conditions": [
            {
              "id": "d45543b3-e96b-49d2-954c-83fee6fae3ec",
              "leftValue": "={{ $json.exitCode }}",
              "rightValue": 0,
              "operator": {
                "type": "number",
                "operation": "equals"
              }
            }
          ],
          "combinator": "and"
        },
        "options": {}
      },
      "type": "n8n-nodes-base.if",
      "typeVersion": 2.2,
      "position": [480, 80],
      "id": "9a85c5d3-2a03-41d1-a07f-a80c3a518c23",
      "name": "檢查金鑰是否匯出成功"
    },
    {
      "parameters": {
        "resource": "fileFolder",
        "queryString": "{{ $json.fileName }}",
        "filter": {
          "folderId": {
            "__rl": true,
            "value": "1DRH1bnl7_dxGMQzRw4fS65iroxP96bIN",
            "mode": "list",
            "cachedResultName": "n8n 機密資料",
            "cachedResultUrl": "https://drive.google.com/drive/folders/1DRH1bnl7_dxGMQzRw4fS65iroxP96bIN"
          }
        },
        "options": {}
      },
      "type": "n8n-nodes-base.googleDrive",
      "typeVersion": 3,
      "position": [920, 40],
      "id": "25dc8ee5-e460-49bc-b26d-745ba76fd0de",
      "name": "檢查備份金鑰",
      "retryOnFail": true,
      "notesInFlow": true,
      "credentials": {
        "googleDriveOAuth2Api": {
          "id": "4rBIaJA0fKbd6mpT",
          "name": "Google Drive (n8n)"
        }
      }
    },
    {
      "parameters": {
        "resource": "fileFolder",
        "queryString": "={{ $json.fileName }}",
        "filter": {
          "folderId": {
            "__rl": true,
            "value": "1tfyMj_8yCNpud_gDzysvfLi0F1Uz7_Sy",
            "mode": "list",
            "cachedResultName": "n8n 工作流程備份",
            "cachedResultUrl": "https://drive.google.com/drive/folders/1tfyMj_8yCNpud_gDzysvfLi0F1Uz7_Sy"
          }
        },
        "options": {}
      },
      "type": "n8n-nodes-base.googleDrive",
      "typeVersion": 3,
      "position": [900, -260],
      "id": "4b2472b9-ffd5-4ccb-a879-a8effd878070",
      "name": "檢查工作流程備份",
      "retryOnFail": true,
      "notesInFlow": true,
      "credentials": {
        "googleDriveOAuth2Api": {
          "id": "4rBIaJA0fKbd6mpT",
          "name": "Google Drive (n8n)"
        }
      }
    },
    {
      "parameters": {
        "operation": "deleteFile",
        "fileId": {
          "__rl": true,
          "value": "={{ $json.id }}",
          "mode": "id"
        },
        "options": {
          "deletePermanently": true
        }
      },
      "type": "n8n-nodes-base.googleDrive",
      "typeVersion": 3,
      "position": [1060, 40],
      "id": "e37dadb6-944b-4b95-9442-05fddbd96681",
      "name": "刪除舊金鑰",
      "retryOnFail": true,
      "alwaysOutputData": false,
      "notesInFlow": true,
      "credentials": {
        "googleDriveOAuth2Api": {
          "id": "4rBIaJA0fKbd6mpT",
          "name": "Google Drive (n8n)"
        }
      }
    },
    {
      "parameters": {
        "driveId": {
          "__rl": true,
          "mode": "list",
          "value": "My Drive"
        },
        "folderId": {
          "__rl": true,
          "value": "1tfyMj_8yCNpud_gDzysvfLi0F1Uz7_Sy",
          "mode": "list",
          "cachedResultName": "n8n 工作流程備份",
          "cachedResultUrl": "https://drive.google.com/drive/folders/1tfyMj_8yCNpud_gDzysvfLi0F1Uz7_Sy"
        },
        "options": {
          "simplifyOutput": true
        }
      },
      "type": "n8n-nodes-base.googleDrive",
      "typeVersion": 3,
      "position": [1000, -120],
      "id": "7c573c4a-e4c4-4039-972b-6da8e4f2c3a5",
      "name": "上傳工作流程備份",
      "notesInFlow": true,
      "retryOnFail": true,
      "credentials": {
        "googleDriveOAuth2Api": {
          "id": "4rBIaJA0fKbd6mpT",
          "name": "Google Drive (n8n)"
        }
      }
    },
    {
      "parameters": {
        "driveId": {
          "__rl": true,
          "value": "My Drive",
          "mode": "list",
          "cachedResultName": "My Drive",
          "cachedResultUrl": "https://drive.google.com/drive/my-drive"
        },
        "folderId": {
          "__rl": true,
          "value": "1DRH1bnl7_dxGMQzRw4fS65iroxP96bIN",
          "mode": "list",
          "cachedResultName": "n8n 機密資料",
          "cachedResultUrl": "https://drive.google.com/drive/folders/1DRH1bnl7_dxGMQzRw4fS65iroxP96bIN"
        },
        "options": {
          "simplifyOutput": true
        }
      },
      "type": "n8n-nodes-base.googleDrive",
      "typeVersion": 3,
      "position": [980, 200],
      "id": "54707f09-1efa-47c4-acd6-cb3bf22193a1",
      "name": "上傳金鑰備份",
      "notesInFlow": true,
      "retryOnFail": true,
      "credentials": {
        "googleDriveOAuth2Api": {
          "id": "4rBIaJA0fKbd6mpT",
          "name": "Google Drive (n8n)"
        }
      }
    },
    {
      "parameters": {},
      "type": "n8n-nodes-base.merge",
      "typeVersion": 3,
      "position": [1240, -140],
      "id": "0c94bf60-d0bf-4098-b59e-96dd4e47c028",
      "name": "完成上傳工作流程",
      "notesInFlow": true
    },
    {
      "parameters": {},
      "type": "n8n-nodes-base.merge",
      "typeVersion": 3,
      "position": [1240, 100],
      "id": "1e2a9d38-b777-479e-8885-3d9b9bab1b31",
      "name": "完成上傳金鑰",
      "notesInFlow": true
    },
    {
      "parameters": {
        "rule": {
          "interval": [
            {
              "triggerAtHour": 6,
              "triggerAtMinute": 5
            }
          ]
        }
      },
      "type": "n8n-nodes-base.scheduleTrigger",
      "typeVersion": 1.2,
      "position": [80, 80],
      "id": "afbde08b-3bbf-4761-b9cd-8321841c55cb",
      "name": "定時"
    },
    {
      "parameters": {},
      "type": "n8n-nodes-base.manualTrigger",
      "typeVersion": 1,
      "position": [80, -140],
      "id": "c58bc948-a22e-40ea-a890-87b7ca1f24a7",
      "name": "手動執行"
    }
  ],
  "connections": {
    "合併流程": {
      "main": [
        [
          {
            "node": "刪除匯出資料",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "刪除匯出資料": {
      "main": [
        [
          {
            "node": "通知",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "匯出工作流程": {
      "main": [
        [
          {
            "node": "檢查工作流程是否匯出成功",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "讀取工作流程備份檔": {
      "main": [
        [
          {
            "node": "檢查工作流程備份",
            "type": "main",
            "index": 0
          },
          {
            "node": "上傳工作流程備份",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "刪除舊備份檔": {
      "main": [
        [
          {
            "node": "完成上傳工作流程",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "匯出金鑰": {
      "main": [
        [
          {
            "node": "檢查金鑰是否匯出成功",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "讀取金鑰備份檔": {
      "main": [
        [
          {
            "node": "檢查備份金鑰",
            "type": "main",
            "index": 0
          },
          {
            "node": "上傳金鑰備份",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "檢查工作流程是否匯出成功": {
      "main": [
        [
          {
            "node": "讀取工作流程備份檔",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "檢查金鑰是否匯出成功": {
      "main": [
        [
          {
            "node": "讀取金鑰備份檔",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "檢查備份金鑰": {
      "main": [
        [
          {
            "node": "刪除舊金鑰",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "檢查工作流程備份": {
      "main": [
        [
          {
            "node": "刪除舊備份檔",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "刪除舊金鑰": {
      "main": [
        [
          {
            "node": "完成上傳金鑰",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "上傳工作流程備份": {
      "main": [
        [
          {
            "node": "完成上傳工作流程",
            "type": "main",
            "index": 1
          }
        ]
      ]
    },
    "上傳金鑰備份": {
      "main": [
        [
          {
            "node": "完成上傳金鑰",
            "type": "main",
            "index": 1
          }
        ]
      ]
    },
    "完成上傳工作流程": {
      "main": [
        [
          {
            "node": "合併流程",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "完成上傳金鑰": {
      "main": [
        [
          {
            "node": "合併流程",
            "type": "main",
            "index": 1
          }
        ]
      ]
    },
    "定時": {
      "main": [
        [
          {
            "node": "匯出金鑰",
            "type": "main",
            "index": 0
          },
          {
            "node": "匯出工作流程",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "手動執行": {
      "main": [
        [
          {
            "node": "匯出金鑰",
            "type": "main",
            "index": 0
          },
          {
            "node": "匯出工作流程",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  },
  "pinData": {},
  "meta": {
    "templateCredsSetupCompleted": true,
    "instanceId": "8a867247c877b5ff77a4eb049ea5f8209724e471ec14aa859e8ef8ecf987b8b3"
  }
}
