8
n8n 中文网amn8n.com

每日创建Contabo VPS实例快照

高级

这是一个IT Ops领域的自动化工作流,包含 29 个节点。主要使用 If, Set, Merge, DateTime, SplitOut 等节点。 每日创建Contabo VPS实例快照

前置要求
  • 可能需要目标 API 的认证凭证

分类

工作流预览
可视化展示节点连接关系,支持缩放和平移
导出工作流
复制以下 JSON 配置到 n8n 导入,即可使用此工作流
{
  "meta": {
    "instanceId": "84ba6d895254e080ac2b4916d987aa66b000f88d4d919a6b9c76848f9b8a7616",
    "templateId": "2403"
  },
  "nodes": [
    {
      "id": "15739f4e-3267-4655-9118-d3c617652f23",
      "name": "设置快照属性",
      "type": "n8n-nodes-base.set",
      "position": [
        3460,
        840
      ],
      "parameters": {
        "options": {},
        "assignments": {
          "assignments": [
            {
              "id": "71a51067-08ed-4300-a831-48f1d7d2ada2",
              "name": "data[0].snapshotId",
              "type": "string",
              "value": "={{ $json.data[0].snapshotId }}"
            },
            {
              "id": "00161e54-f324-4f6e-a5df-d27d1c4b7706",
              "name": "displayName",
              "type": "string",
              "value": "={{ $json.displayName }}"
            },
            {
              "id": "b4fbf9e6-c634-4dc7-b75e-44aa048b2e32",
              "name": "instanceId",
              "type": "number",
              "value": "={{ $json.instanceId }}"
            }
          ]
        }
      },
      "typeVersion": 3.4
    },
    {
      "id": "c82ed7b8-c723-46eb-b0fc-1d9da7265a1a",
      "name": "由 Github 模型提供支持",
      "type": "n8n-nodes-base.scheduleTrigger",
      "position": [
        540,
        660
      ],
      "parameters": {
        "rule": {
          "interval": [
            {}
          ]
        }
      },
      "typeVersion": 1.2
    },
    {
      "id": "68b9319b-00b8-480b-b8bc-447e78d4e983",
      "name": "当点击\"测试工作流\"时",
      "type": "n8n-nodes-base.manualTrigger",
      "position": [
        540,
        880
      ],
      "parameters": {},
      "typeVersion": 1
    },
    {
      "id": "657f763f-fc10-4d71-aabd-c9af6c041f4f",
      "name": "凭据",
      "type": "n8n-nodes-base.set",
      "position": [
        1260,
        780
      ],
      "parameters": {
        "options": {},
        "assignments": {
          "assignments": [
            {
              "id": "135cfcc3-050e-4128-b6b0-b8905d160498",
              "name": "CLIENT_ID",
              "type": "string",
              "value": ""
            },
            {
              "id": "b05aa3e9-80c6-474f-b653-8e49654e3da7",
              "name": "CLIENT_SECRET",
              "type": "string",
              "value": ""
            },
            {
              "id": "72c345ba-674e-4db2-946e-bb4a9e6f8763",
              "name": "API_USER",
              "type": "string",
              "value": ""
            },
            {
              "id": "7d1d03e3-86cc-4fd1-9d2a-a3771d913565",
              "name": "API_PASSWORD",
              "type": "string",
              "value": ""
            }
          ]
        }
      },
      "typeVersion": 3.4
    },
    {
      "id": "c74b0511-0eaf-4ae5-b6f2-8dd06186e826",
      "name": "便签",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        1200,
        480
      ],
      "parameters": {
        "width": 427,
        "height": 519,
        "content": "## 凭据"
      },
      "typeVersion": 1
    },
    {
      "id": "4d991799-ba21-4154-886b-d25901245176",
      "name": "授权",
      "type": "n8n-nodes-base.httpRequest",
      "position": [
        1460,
        780
      ],
      "parameters": {
        "url": "https://auth.contabo.com/auth/realms/contabo/protocol/openid-connect/token",
        "method": "POST",
        "options": {},
        "sendBody": true,
        "sendHeaders": true,
        "bodyParameters": {
          "parameters": [
            {
              "name": "client_id",
              "value": "={{ $json.CLIENT_ID }}"
            },
            {
              "name": "client_secret",
              "value": "={{ $json.CLIENT_SECRET }}"
            },
            {
              "name": "username",
              "value": "={{ $json.API_USER }}"
            },
            {
              "name": "password",
              "value": "={{ $json.API_PASSWORD }}"
            },
            {
              "name": "grant_type",
              "value": "password"
            }
          ]
        },
        "headerParameters": {
          "parameters": [
            {
              "name": "Content-Type",
              "value": "application/x-www-form-urlencoded"
            }
          ]
        }
      },
      "typeVersion": 4.2
    },
    {
      "id": "c9bd2ce9-5587-4155-b3ca-192caa48be4c",
      "name": "列出实例",
      "type": "n8n-nodes-base.httpRequest",
      "position": [
        2240,
        780
      ],
      "parameters": {
        "url": "https://api.contabo.com/v1/compute/instances",
        "options": {},
        "sendHeaders": true,
        "headerParameters": {
          "parameters": [
            {
              "name": "Content-Type",
              "value": "application/json"
            },
            {
              "name": "Authorization",
              "value": "={{ $('Authorization').item.json['token_type'] }} {{ $('Authorization').item.json['access_token'] }}"
            },
            {
              "name": "x-request-id",
              "value": "={{ $('UUID').item.json['data'] }}"
            },
            {
              "name": "x-trace-id",
              "value": "={{ $('TRACE ID').item.json['data'] }}"
            }
          ]
        }
      },
      "typeVersion": 4.2
    },
    {
      "id": "52caf65c-d46a-4ff0-8b01-5ced05fd083d",
      "name": "拆分输出",
      "type": "n8n-nodes-base.splitOut",
      "position": [
        2440,
        780
      ],
      "parameters": {
        "options": {},
        "fieldToSplitOut": "data"
      },
      "typeVersion": 1
    },
    {
      "id": "e152da50-7067-4f9d-91a0-564626633330",
      "name": "UUID",
      "type": "n8n-nodes-base.httpRequest",
      "position": [
        1740,
        780
      ],
      "parameters": {
        "url": "https://www.uuidgenerator.net/api/version4",
        "options": {}
      },
      "typeVersion": 4.2
    },
    {
      "id": "8c86a299-d8b3-4806-b885-37d67e9ba8a4",
      "name": "TRACE ID",
      "type": "n8n-nodes-base.httpRequest",
      "position": [
        1960,
        780
      ],
      "parameters": {
        "url": "https://www.uuidgenerator.net/api/version4",
        "options": {}
      },
      "typeVersion": 4.2
    },
    {
      "id": "6ab188c6-dfc3-4e9e-83b8-32bc778917e4",
      "name": "便签1",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        1720,
        477.28137513294257
      ],
      "parameters": {
        "width": 411.2199570815453,
        "height": 521.9218381008977,
        "content": "## 获取 UUID"
      },
      "typeVersion": 1
    },
    {
      "id": "41364273-55db-411b-a59a-0faf01857806",
      "name": "列出快照",
      "type": "n8n-nodes-base.httpRequest",
      "position": [
        2860,
        680
      ],
      "parameters": {
        "url": "=https://api.contabo.com/v1/compute/instances/{{ $('Split Out').item.json['instanceId'] }}/snapshots",
        "options": {},
        "sendHeaders": true,
        "headerParameters": {
          "parameters": [
            {
              "name": "Content-Type",
              "value": "application/json"
            },
            {
              "name": "Authorization",
              "value": "={{ $('Authorization').item.json['token_type'] }} {{ $('Authorization').item.json['access_token'] }}"
            },
            {
              "name": "x-request-id",
              "value": "={{ $('UUID1').item.json['data'] }}"
            },
            {
              "name": "x-trace-id",
              "value": "={{ $('TRACE ID').item.json['data'] }}"
            }
          ]
        }
      },
      "typeVersion": 4.2
    },
    {
      "id": "919fed8d-704e-4b1f-9358-f2a4422b7132",
      "name": "UUID1",
      "type": "n8n-nodes-base.httpRequest",
      "position": [
        2680,
        680
      ],
      "parameters": {
        "url": "https://www.uuidgenerator.net/api/version4",
        "options": {}
      },
      "typeVersion": 4.2
    },
    {
      "id": "630975b0-41f6-4025-9b7e-a464c2b5f4fa",
      "name": "便签2",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        2200,
        480
      ],
      "parameters": {
        "width": 384,
        "height": 279,
        "content": "## 列出您的实例"
      },
      "typeVersion": 1
    },
    {
      "id": "f1a39319-5743-4836-8840-5d2b51746682",
      "name": "便签3",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        2640,
        480
      ],
      "parameters": {
        "width": 733.0237288135586,
        "height": 467.2593220338978,
        "content": "## 列出现有快照"
      },
      "typeVersion": 1
    },
    {
      "id": "5f453f4f-f509-4613-9692-c16e1a8d3c53",
      "name": "合并",
      "type": "n8n-nodes-base.merge",
      "position": [
        3040,
        820
      ],
      "parameters": {
        "mode": "combine",
        "options": {},
        "combineBy": "combineByPosition"
      },
      "typeVersion": 3
    },
    {
      "id": "2e12506f-4e8d-4053-b662-d1ff9d33ecf7",
      "name": "获取日期和时间",
      "type": "n8n-nodes-base.dateTime",
      "position": [
        840,
        780
      ],
      "parameters": {
        "options": {
          "timezone": "America/Sao_Paulo"
        }
      },
      "retryOnFail": true,
      "typeVersion": 2
    },
    {
      "id": "c06bf642-253f-4cec-8c0f-97edff450c1b",
      "name": "删除现有快照",
      "type": "n8n-nodes-base.httpRequest",
      "position": [
        3780,
        840
      ],
      "parameters": {
        "url": "=https://api.contabo.com/v1/compute/instances/{{ $('Set snapshot attributes').item.json['instanceId'] }}/snapshots/{{ $('Set snapshot attributes').item.json['data'][0].snapshotId }}",
        "method": "DELETE",
        "options": {},
        "sendHeaders": true,
        "headerParameters": {
          "parameters": [
            {
              "name": "Content-Type",
              "value": "application/json"
            },
            {
              "name": "Authorization",
              "value": "={{ $('Authorization').item.json['token_type'] }} {{ $('Authorization').item.json['access_token'] }}"
            },
            {
              "name": "x-request-id",
              "value": "={{ $('UUID3').item.json['data'] }}"
            },
            {
              "name": "x-trace-id",
              "value": "={{ $('TRACE ID').item.json['data'] }}"
            }
          ]
        }
      },
      "retryOnFail": true,
      "typeVersion": 4.2
    },
    {
      "id": "f7a1d94d-c10d-400a-b9ed-7135def2d809",
      "name": "创建新快照",
      "type": "n8n-nodes-base.httpRequest",
      "position": [
        4360,
        660
      ],
      "parameters": {
        "url": "=https://api.contabo.com/v1/compute/instances/{{ $('set snapshot attributes').item.json['instanceId'] }}/snapshots",
        "method": "POST",
        "options": {},
        "sendBody": true,
        "sendHeaders": true,
        "bodyParameters": {
          "parameters": [
            {
              "name": "name",
              "value": "={{ $('Formatted Date').item.json['formattedDate'] }}"
            },
            {
              "name": "description",
              "value": "={{ $('set snapshot attributes').item.json['displayName'] }} {{ $('Formatted Date').item.json['formattedDate'] }}"
            }
          ]
        },
        "headerParameters": {
          "parameters": [
            {
              "name": "Content-Type",
              "value": "application/json"
            },
            {
              "name": "Authorization",
              "value": "={{ $('Authorization').item.json['token_type'] }} {{ $('Authorization').item.json['access_token'] }}"
            },
            {
              "name": "x-request-id",
              "value": "={{ $('UUID2').item.json['data'] }}"
            },
            {
              "name": "x-trace-id",
              "value": "={{ $('TRACE ID').item.json['data'] }}"
            }
          ]
        }
      },
      "retryOnFail": true,
      "typeVersion": 4.2
    },
    {
      "id": "dfc5ba84-89e3-4567-a466-393016843391",
      "name": "创建新快照1",
      "type": "n8n-nodes-base.httpRequest",
      "position": [
        4200,
        840
      ],
      "parameters": {
        "url": "=https://api.contabo.com/v1/compute/instances/{{ $('Set snapshot attributes').item.json['instanceId'] }}/snapshots",
        "method": "POST",
        "options": {},
        "sendBody": true,
        "sendHeaders": true,
        "bodyParameters": {
          "parameters": [
            {
              "name": "name",
              "value": "={{ $('Formatted Date').item.json['formattedDate'] }}"
            },
            {
              "name": "description",
              "value": "={{ $('Set snapshot attributes').item.json['displayName'] }} {{ $('Formatted Date').item.json['formattedDate'] }}"
            }
          ]
        },
        "headerParameters": {
          "parameters": [
            {
              "name": "Content-Type",
              "value": "application/json"
            },
            {
              "name": "Authorization",
              "value": "={{ $('Authorization').item.json['token_type'] }} {{ $('Authorization').item.json['access_token'] }}"
            },
            {
              "name": "x-request-id",
              "value": "={{ $('UUID4').item.json['data'] }}"
            },
            {
              "name": "x-trace-id",
              "value": "={{ $('TRACE ID').item.json['data'] }}"
            }
          ]
        }
      },
      "retryOnFail": true,
      "typeVersion": 4.2
    },
    {
      "id": "d6b69037-14a9-4e01-be34-a7975503554d",
      "name": "UUID2",
      "type": "n8n-nodes-base.httpRequest",
      "position": [
        4200,
        660
      ],
      "parameters": {
        "url": "https://www.uuidgenerator.net/api/version4",
        "options": {}
      },
      "typeVersion": 4.2
    },
    {
      "id": "1d80d4d5-1f5f-4cf1-9540-8a4b84edda38",
      "name": "UUID3",
      "type": "n8n-nodes-base.httpRequest",
      "position": [
        3620,
        840
      ],
      "parameters": {
        "url": "https://www.uuidgenerator.net/api/version4",
        "options": {}
      },
      "typeVersion": 4.2
    },
    {
      "id": "f3ede6e8-5ca2-418b-8e60-03b817857cf2",
      "name": "UUID4",
      "type": "n8n-nodes-base.httpRequest",
      "position": [
        4020,
        840
      ],
      "parameters": {
        "url": "https://www.uuidgenerator.net/api/version4",
        "options": {}
      },
      "typeVersion": 4.2
    },
    {
      "id": "d1995aef-531f-471e-a16d-7c75b1f3ae4c",
      "name": "便签4",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        3440,
        480
      ],
      "parameters": {
        "width": 486.8901611698841,
        "height": 467.87473554386463,
        "content": "## 按 ID 删除现有快照"
      },
      "typeVersion": 1
    },
    {
      "id": "8b408e6d-9574-4fa4-bc7e-7a543aa0bad6",
      "name": "便签5",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        3980,
        480
      ],
      "parameters": {
        "width": 576.6684015952959,
        "height": 468.61270146235483,
        "content": "## 创建新快照"
      },
      "typeVersion": 1
    },
    {
      "id": "a41e7b87-8e46-44ea-8ca5-08f7d1a36f47",
      "name": "### 需要帮助?",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        380,
        240
      ],
      "parameters": {
        "width": 769.2098244001793,
        "height": 415.52346358766624,
        "content": "## Contabo 备份工作流"
      },
      "typeVersion": 1
    },
    {
      "id": "eb412eff-cf8b-44e8-b0ad-21798504f11d",
      "name": "格式化日期",
      "type": "n8n-nodes-base.dateTime",
      "position": [
        1020,
        780
      ],
      "parameters": {
        "date": "={{ $json.currentDate }}",
        "format": "custom",
        "options": {},
        "operation": "formatDate",
        "customFormat": "dd-MM-yyyy"
      },
      "typeVersion": 2
    },
    {
      "id": "67413ee0-38db-4917-adcd-be9c6cb4f5cc",
      "name": "是否存在快照",
      "type": "n8n-nodes-base.if",
      "position": [
        3220,
        820
      ],
      "parameters": {
        "options": {},
        "conditions": {
          "options": {
            "leftValue": "",
            "caseSensitive": true,
            "typeValidation": "strict"
          },
          "combinator": "and",
          "conditions": [
            {
              "id": "2bd58580-020f-411b-b25d-e63467d615bc",
              "operator": {
                "type": "array",
                "operation": "empty",
                "singleValue": true
              },
              "leftValue": "={{ $('List snapshots').item.json['data'] }}",
              "rightValue": ""
            }
          ]
        }
      },
      "typeVersion": 2
    },
    {
      "id": "464f52f5-bc1d-402c-81d2-4db24f675871",
      "name": "设置快照属性",
      "type": "n8n-nodes-base.set",
      "position": [
        4020,
        660
      ],
      "parameters": {
        "options": {},
        "assignments": {
          "assignments": [
            {
              "id": "b9af7eb7-bd87-4949-ac95-e40025c3c419",
              "name": "instanceId",
              "type": "string",
              "value": "={{ $json.instanceId }}"
            },
            {
              "id": "3d8cb230-4512-4b65-be3a-6ea59cb80ddd",
              "name": "displayName",
              "type": "string",
              "value": "={{ $json.displayName }}"
            }
          ]
        }
      },
      "typeVersion": 3.4
    }
  ],
  "pinData": {},
  "connections": {
    "UUID": {
      "main": [
        [
          {
            "node": "TRACE ID",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Merge": {
      "main": [
        [
          {
            "node": "Whether snapshot there is no snapshot",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "UUID1": {
      "main": [
        [
          {
            "node": "List snapshots",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "UUID2": {
      "main": [
        [
          {
            "node": "Create a new snapshot",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "UUID3": {
      "main": [
        [
          {
            "node": "Delete existing snapshot",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "UUID4": {
      "main": [
        [
          {
            "node": "Create a new snapshot1",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "TRACE ID": {
      "main": [
        [
          {
            "node": "List instances",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Split Out": {
      "main": [
        [
          {
            "node": "UUID1",
            "type": "main",
            "index": 0
          },
          {
            "node": "Merge",
            "type": "main",
            "index": 1
          }
        ]
      ]
    },
    "Credential": {
      "main": [
        [
          {
            "node": "Authorization",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Authorization": {
      "main": [
        [
          {
            "node": "UUID",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Formatted Date": {
      "main": [
        [
          {
            "node": "Credential",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "List instances": {
      "main": [
        [
          {
            "node": "Split Out",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "List snapshots": {
      "main": [
        [
          {
            "node": "Merge",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "get Date & Time": {
      "main": [
        [
          {
            "node": "Formatted Date",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Schedule Trigger": {
      "main": [
        [
          {
            "node": "get Date & Time",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Set snapshot attributes": {
      "main": [
        [
          {
            "node": "UUID3",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "set snapshot attributes": {
      "main": [
        [
          {
            "node": "UUID2",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Delete existing snapshot": {
      "main": [
        [
          {
            "node": "UUID4",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "When clicking ‘Test workflow’": {
      "main": [
        [
          {
            "node": "get Date & Time",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Whether snapshot there is no snapshot": {
      "main": [
        [
          {
            "node": "set snapshot attributes",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Set snapshot attributes",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  }
}
常见问题

如何使用这个工作流?

复制上方的 JSON 配置代码,在您的 n8n 实例中创建新工作流并选择「从 JSON 导入」,粘贴配置后根据需要修改凭证设置即可。

这个工作流适合什么场景?

高级 - IT 运维

需要付费吗?

本工作流完全免费,您可以直接导入使用。但请注意,工作流中使用的第三方服务(如 OpenAI API)可能需要您自行付费。

工作流信息
难度等级
高级
节点数量29
分类1
节点类型9
难度说明

适合高级用户,包含 16+ 个节点的复杂工作流

作者
DUBCOM

DUBCOM

@dubcom

I've spent six years as a fullstack developer, focusing on marketing automation with n8n for three years. I integrate systems, automate workflows, and optimize campaigns to enhance efficiency and drive growth in marketing strategies. 🇧🇷🇧🇷🇧🇷🇧🇷

外部链接
在 n8n.io 查看

分享此工作流