{
  "name": "Scheduled Database Backup to Google Drive",
  "nodes": [
    {
      "parameters": {
        "rule": {
          "interval": [{ "field": "days", "daysInterval": 1, "triggerAtHour": 3 }]
        }
      },
      "id": "sbdr0001-0001-4000-8000-000000000001",
      "name": "Daily Backup Trigger",
      "type": "n8n-nodes-base.scheduleTrigger",
      "typeVersion": 1,
      "position": [240, 300]
    },
    {
      "parameters": {
        "method": "GET",
        "url": "={{ $env.BACKUP_API_URL }}/export",
        "sendHeaders": true,
        "headerParameters": {
          "parameters": [
            { "name": "Authorization", "value": "Bearer {{ $env.BACKUP_API_KEY }}" },
            { "name": "Accept", "value": "application/json" }
          ]
        },
        "options": { "timeout": 60000 }
      },
      "id": "sbdr0001-0002-4000-8000-000000000002",
      "name": "Fetch Data Export",
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 4,
      "position": [460, 300]
    },
    {
      "parameters": {
        "jsCode": "const d = items[0].json;\nconst dateStr = new Date().toISOString().slice(0, 10);\nconst content = JSON.stringify(d, null, 2);\nreturn [{ json: { filename: `backup-${dateStr}.json`, content, size_bytes: content.length, exported_at: new Date().toISOString() } }];"
      },
      "id": "sbdr0001-0003-4000-8000-000000000003",
      "name": "Prepare Backup File",
      "type": "n8n-nodes-base.code",
      "typeVersion": 2,
      "position": [680, 300]
    },
    {
      "parameters": {
        "operation": "upload",
        "name": "={{ $json.filename }}",
        "driveId": { "__rl": true, "mode": "id", "value": "={{ $env.DRIVE_FOLDER_ID }}" },
        "folderId": { "__rl": true, "mode": "id", "value": "={{ $env.DRIVE_FOLDER_ID }}" },
        "binaryPropertyName": "data",
        "options": {
          "convertToGoogleDocs": false
        }
      },
      "id": "sbdr0001-0004-4000-8000-000000000004",
      "name": "Upload to Google Drive",
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 4,
      "position": [900, 300]
    },
    {
      "parameters": {
        "select": "channel",
        "channelId": { "__rl": true, "mode": "id", "value": "={{ $env.SLACK_OPS_CHANNEL }}" },
        "text": ":floppy_disk: *Daily Backup Complete*\n*File:* {{ $('Prepare Backup File').item.json.filename }}\n*Size:* {{ $('Prepare Backup File').item.json.size_bytes }} bytes\n*Uploaded to Drive at:* {{ $('Prepare Backup File').item.json.exported_at }}",
        "otherOptions": {}
      },
      "id": "sbdr0001-0005-4000-8000-000000000005",
      "name": "Notify Slack Backup Done",
      "type": "n8n-nodes-base.slack",
      "typeVersion": 2,
      "position": [1120, 300]
    }
  ],
  "connections": {
    "Daily Backup Trigger": {
      "main": [[{ "node": "Fetch Data Export", "type": "main", "index": 0 }]]
    },
    "Fetch Data Export": {
      "main": [[{ "node": "Prepare Backup File", "type": "main", "index": 0 }]]
    },
    "Prepare Backup File": {
      "main": [[{ "node": "Upload to Google Drive", "type": "main", "index": 0 }]]
    },
    "Upload to Google Drive": {
      "main": [[{ "node": "Notify Slack Backup Done", "type": "main", "index": 0 }]]
    }
  },
  "active": false,
  "settings": { "executionOrder": "v1" },
  "meta": {},
  "pinData": {}
}
