{
  "name": "Nodbot - n8n Docker Compose backup to S3",
  "nodes": [
    {
      "parameters": {},
      "id": "93ae99f0-da63-40fe-9ec6-f7c13120f0a6",
      "name": "Schedule nightly",
      "type": "n8n-nodes-base.scheduleTrigger",
      "typeVersion": 2,
      "position": [
        0,
        260
      ]
    },
    {
      "parameters": {
        "jsCode": "const src = $json.body ?? $json;\nconst now = new Date();\nconst stamp = now.toISOString().replace(/[:.]/g, '-');\nconst name = String(src.backup_name ?? 'n8n-prod').replace(/[^a-z0-9_-]/gi, '-').toLowerCase();\nconst retentionDays = Number(src.retention_days ?? 30);\nif (retentionDays < 7) throw new Error('Retention must be at least 7 days for production n8n');\n\nreturn [{\n  json: {\n    backup_id: `${name}-${stamp}`,\n    pg_file: `/tmp/${name}-${stamp}.pgdump`,\n    workflows_file: `/tmp/${name}-${stamp}-workflows.json`,\n    archive_file: `/tmp/${name}-${stamp}.tar.gz`,\n    s3_prefix: String(src.s3_bucket ?? '').replace(/\\/$/, ''),\n    retention_days: retentionDays,\n    restore_test_required: src.restore_test !== false,\n    labels: { app: 'n8n', type: 'backup', environment: 'production' }\n  }\n}];"
      },
      "id": "55b47b56-465b-4f9f-99e8-135b6777d1cc",
      "name": "Prepare backup id Code",
      "type": "n8n-nodes-base.code",
      "typeVersion": 2,
      "position": [
        280,
        260
      ]
    },
    {
      "parameters": {},
      "id": "57062cea-e4a7-4e39-8413-6aeeb8e15e67",
      "name": "Run pg_dump SSH",
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 2,
      "position": [
        560,
        260
      ]
    },
    {
      "parameters": {},
      "id": "0126de43-9d93-4269-9ab0-356505e05abd",
      "name": "Export workflows SSH",
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 2,
      "position": [
        840,
        260
      ]
    },
    {
      "parameters": {},
      "id": "55443c26-a264-4d16-a75d-9be33c5a4bf4",
      "name": "Upload to S3 HTTP",
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 2,
      "position": [
        1120,
        260
      ]
    },
    {
      "parameters": {},
      "id": "2070c588-f319-464c-a37f-3f6c3d48c202",
      "name": "Notify result Telegram",
      "type": "n8n-nodes-base.telegram",
      "typeVersion": 2,
      "position": [
        1400,
        260
      ]
    }
  ],
  "connections": {
    "Schedule nightly": {
      "main": [
        [
          {
            "node": "Prepare backup id Code",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Prepare backup id Code": {
      "main": [
        [
          {
            "node": "Run pg_dump SSH",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Run pg_dump SSH": {
      "main": [
        [
          {
            "node": "Export workflows SSH",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Export workflows SSH": {
      "main": [
        [
          {
            "node": "Upload to S3 HTTP",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Upload to S3 HTTP": {
      "main": [
        [
          {
            "node": "Notify result Telegram",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  },
  "pinData": {},
  "settings": {
    "executionOrder": "v1"
  },
  "staticData": null,
  "tags": [
    "nodbot",
    "production",
    "template"
  ],
  "triggerCount": 1,
  "updatedAt": "2026-05-30T00:00:00.000Z",
  "versionId": "334769a7-2b12-428b-bed6-db29af590c77",
  "meta": {
    "templateCredsSetupCompleted": false
  }
}