VPS.org API

REST API دستاويزي

بيڪ اپ API

سرور بيڪ اپ کي پروگرام جي لحاظ کان منظم ڪريو. پنهنجي سرورز لاءِ بيڪ اپ لسٽ ڪريو، ٺاهيو، بحال ڪريو، ۽ ختم ڪريو.

آخري نقطا 3 endpoints
بنيادي رستو /api/v1/backups
حاصل ڪريو /api/v1/backups/

سڀ بيڪ اپ لسٽ ڪريو

پنهنجي سرورن تي سڀني بيڪ اپن جي فهرست حاصل ڪريو.

سوال جا پيرا ميٽر

پيرا ميٽر قسم گهربل وضاحت
server_id integer نه سرور ID جي ذريعي بيڪ اپ فلٽر ڪريو
backup_type string نه قسم جي لحاظ کان فلٽر ڪريو: manual ، automatic

مثال جي درخواست

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);

مثال جواب

{
  "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"
    }
  ]
}

جوابي اسٽيٽس ڪوڊس

200 بيڪ اپ لسٽ ڪاميابي سان حاصل ڪئي وئي.
401 غير مجاز - غلط يا گم ٿيل تصديق ٽوڪن
پوسٽ ڪريو /api/v1/backups/

دستي بيڪ اپ ٺاهيو

سرور جو مينوئل بيڪ اپ ٺاهيو. مينوئل بيڪ اپ پاڻمرادو ختم نه ٿيندا آهن.

درخواست باڊي پيرا ميٽرز

پيرا ميٽر قسم گهربل وضاحت
server_id integer ها بيڪ اپ لاءِ سرور جي سڃاڻپ
description string نه بيڪ اپ لاءِ اختياري وضاحت

مثال جي درخواست

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);

مثال جواب

{
  "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."
}

جوابي اسٽيٽس ڪوڊس

201 بيڪ اپ ٺاهڻ ڪاميابي سان شروع ٿي ويو.
400 خراب درخواست - غلط پيرا ميٽرز يا خراب فارميٽ واري درخواست
401 غير مجاز - غلط يا گم ٿيل تصديق ٽوڪن
404 نه مليو - سرور موجود ناهي
نوٽ: توهان هر سرور تي وڌ ۾ وڌ 10 دستي بيڪ اپ رکي سگهو ٿا. خودڪار بيڪ اپ توهان جي پلان جي بيڪ اپ برقرار رکڻ واري پاليسي (عام طور تي 7-30 ڏينهن) جي بنياد تي برقرار رکيا ويندا آهن.
ختم ڪريو /api/v1/backups/{backup_id}/

بيڪ اپ ختم ڪريو

مستقل طور تي بيڪ اپ ختم ڪريو. هي عمل واپس نه ٿو ڪري سگهجي.

رستي جا پيرا ميٽر

پيرا ميٽر قسم گهربل وضاحت
backup_id integer ها منفرد بيڪ اپ ID

مثال جي درخواست

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);

جوابي اسٽيٽس ڪوڊس

204 بيڪ اپ ڪاميابي سان ڊهي ويو.
401 غير مجاز - غلط يا گم ٿيل تصديق ٽوڪن
404 نه مليو - بيڪ اپ موجود ناهي
خبردار: بيڪ اپ کي حذف ڪرڻ مستقل آهي ۽ ان کي واپس نه ٿو ڪري سگهجي. پڪ ڪريو ته توهان کي هاڻي هن بيڪ اپ کي حذف ڪرڻ کان اڳ ضرورت ناهي.

بيڪ اپ مان بحال ڪرڻ

بيڪ اپ مان سرور کي بحال ڪرڻ لاءِ، سرورز API بحالي اينڊ پوائنٽ استعمال ڪريو:

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

سرور جي بحالي بابت تفصيلي ڄاڻ لاءِ، ڏسو سرورز API دستاويز.

بيڪ اپ بهترين طريقا