VPS.org API

Dogfennaeth API REST

API Copïau Wrth Gefn

Rheoli copïau wrth gefn gweinyddion yn rhaglennol. Rhestru, creu, adfer a dileu copïau wrth gefn ar gyfer eich gweinyddion.

Pwyntiau terfyn 3 endpoints
Llwybr Sylfaen /api/v1/backups
CAEL /api/v1/backups/

Rhestru Pob Copïau Wrth Gefn

Adalw rhestr o'r holl gopïau wrth gefn ar draws eich gweinyddion.

Paramedrau'r Ymholiad

Paramedr Math Angenrheidiol Disgrifiad
server_id integer Na Hidlo copïau wrth gefn yn ôl ID gweinydd
backup_type string Na Hidlo yn ôl math: manual , automatic

Cais Enghraifft

cURL
Python
JavaScript
curl -X GET "https://admin.vps.org/api/v1/backups/?server_id=12345" \
  -H "Authorization: Bearer YOUR_API_TOKEN" \
  -H "Content-Type: application/json"
import requests

url = "https://admin.vps.org/api/v1/backups/"
headers = {
    "Authorization": "Bearer YOUR_API_TOKEN",
    "Content-Type": "application/json"
}
params = {"server_id": 12345}

response = requests.get(url, headers=headers, params=params)
print(response.json())
const response = await fetch('https://admin.vps.org/api/v1/backups/?server_id=12345', {
  method: 'GET',
  headers: {
    'Authorization': 'Bearer YOUR_API_TOKEN',
    'Content-Type': 'application/json'
  }
});

const backups = await response.json();
console.log(backups);

Ymateb Enghraifft

{
  "count": 3,
  "results": [
    {
      "id": 501,
      "server": {
        "id": 12345,
        "name": "web-server-01"
      },
      "backup_type": "automatic",
      "status": "completed",
      "size_mb": 4523,
      "created_at": "2025-01-16T03:00:00Z",
      "expires_at": "2025-02-16T03:00:00Z",
      "description": "Automatic daily backup"
    },
    {
      "id": 499,
      "server": {
        "id": 12345,
        "name": "web-server-01"
      },
      "backup_type": "manual",
      "status": "completed",
      "size_mb": 4456,
      "created_at": "2025-01-14T10:30:00Z",
      "expires_at": null,
      "description": "Pre-update backup"
    },
    {
      "id": 495,
      "server": {
        "id": 12345,
        "name": "web-server-01"
      },
      "backup_type": "automatic",
      "status": "completed",
      "size_mb": 4389,
      "created_at": "2025-01-15T03:00:00Z",
      "expires_at": "2025-02-15T03:00:00Z",
      "description": "Automatic daily backup"
    }
  ]
}

Codau Statws Ymateb

200 Adalwyd rhestr wrth gefn yn llwyddiannus
401 Heb awdurdod - Tocyn dilysu annilys neu ar goll
POST /api/v1/backups/

Creu Copi Wrth Gefn â Llaw

Creu copi wrth gefn â llaw o weinydd. Nid yw copïau wrth gefn â llaw yn dod i ben yn awtomatig.

Paramedrau Corff y Cais

Paramedr Math Angenrheidiol Disgrifiad
server_id integer Ie ID y gweinydd i'w gopïo wrth gefn
description string Na Disgrifiad dewisol ar gyfer y copi wrth gefn

Cais Enghraifft

cURL
Python
JavaScript
PHP
curl -X POST "https://admin.vps.org/api/v1/backups/" \
  -H "Authorization: Bearer YOUR_API_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{
    "server_id": 12345,
    "description": "Pre-deployment backup"
  }'
import requests

url = "https://admin.vps.org/api/v1/backups/"
headers = {
    "Authorization": "Bearer YOUR_API_TOKEN",
    "Content-Type": "application/json"
}
data = {
    "server_id": 12345,
    "description": "Pre-deployment backup"
}

response = requests.post(url, headers=headers, json=data)
print(response.json())
const response = await fetch('https://admin.vps.org/api/v1/backups/', {
  method: 'POST',
  headers: {
    'Authorization': 'Bearer YOUR_API_TOKEN',
    'Content-Type': 'application/json'
  },
  body: JSON.stringify({
    server_id: 12345,
    description: 'Pre-deployment backup'
  })
});

const backup = await response.json();
console.log(backup);
$data = [
    'server_id' => 12345,
    'description' => 'Pre-deployment backup'
];

$ch = curl_init('https://admin.vps.org/api/v1/backups/');
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($data));
curl_setopt($ch, CURLOPT_HTTPHEADER, [
    'Authorization: Bearer YOUR_API_TOKEN',
    'Content-Type: application/json'
]);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);

$response = curl_exec($ch);
$backup = json_decode($response, true);
curl_close($ch);

Ymateb Enghraifft

{
  "id": 502,
  "server": {
    "id": 12345,
    "name": "web-server-01"
  },
  "backup_type": "manual",
  "status": "in_progress",
  "size_mb": null,
  "created_at": "2025-01-16T15:45:00Z",
  "expires_at": null,
  "description": "Pre-deployment backup",
  "message": "Backup is being created. This may take several minutes depending on server size."
}

Codau Statws Ymateb

201 Cychwynnwyd creu copi wrth gefn yn llwyddiannus
400 Cais Gwael - Paramedrau annilys neu gais wedi'i gamffurfio
401 Heb awdurdod - Tocyn dilysu annilys neu ar goll
404 Heb ei Ganfod - Nid yw'r Gweinydd yn bodoli
Nodyn: Gallwch gael uchafswm o 10 copi wrth gefn â llaw fesul gweinydd. Cedwir copïau wrth gefn awtomatig yn seiliedig ar bolisi cadw copi wrth gefn eich cynllun (fel arfer 7-30 diwrnod).
DILEU /api/v1/backups/{backup_id}/

Dileu copi wrth gefn

Dileu copi wrth gefn yn barhaol. Ni ellir dadwneud y weithred hon.

Paramedrau Llwybr

Paramedr Math Angenrheidiol Disgrifiad
backup_id integer Ie ID wrth gefn unigryw

Cais Enghraifft

cURL
Python
JavaScript
curl -X DELETE "https://admin.vps.org/api/v1/backups/501/" \
  -H "Authorization: Bearer YOUR_API_TOKEN" \
  -H "Content-Type: application/json"
import requests

backup_id = 501
url = f"https://admin.vps.org/api/v1/backups/{backup_id}/"
headers = {
    "Authorization": "Bearer YOUR_API_TOKEN",
    "Content-Type": "application/json"
}

response = requests.delete(url, headers=headers)
print(response.status_code)
const backupId = 501;
const response = await fetch(`https://admin.vps.org/api/v1/backups/${backupId}/`, {
  method: 'DELETE',
  headers: {
    'Authorization': 'Bearer YOUR_API_TOKEN',
    'Content-Type': 'application/json'
  }
});

console.log(response.status);

Codau Statws Ymateb

204 Dilewyd copi wrth gefn yn llwyddiannus
401 Heb awdurdod - Tocyn dilysu annilys neu ar goll
404 Heb ei Ganfod - Nid yw copi wrth gefn yn bodoli
Rhybudd: Mae dileu copi wrth gefn yn barhaol ac ni ellir ei ddadwneud. Gwnewch yn siŵr nad oes angen y copi wrth gefn hwn arnoch mwyach cyn ei ddileu.

Adfer o gopïau wrth gefn

I adfer gweinydd o gopi wrth gefn, defnyddiwch bwynt terfynol adfer API y Gweinyddion :

POST /api/v1/servers/{server_id}/restore/
{
  "backup_id": 501
}

Am wybodaeth fanwl am adfer gweinydd, gweler y Dogfennaeth API gweinyddion.

Arferion Gorau ar gyfer Copïau Wrth Gefn