Use the Restore VPS Backups API to restore the backup of the VPS. Virtualizor allows you to restore the VPS to the original VPS or create a new VPS altogether using the backup image. To get the details of the backup directory and the date use the Backup VPS Details API. The API response will contain "restore_done" as "true" after the restoration process is initiated.
For more information, you can refer this Backup Plans guide.
HTTP Request
https://hostname:4085/index.php?act= vpsrestore
Parameters
Name | Method | Value | Description | Required |
---|---|---|---|---|
act | GET | vpsrestore | This action will restore the vps whose backup exists and return restore_done as true | Yes |
vpsid | POST | Int | The ID of vps which needs to be restored | Yes |
bid | POST | Int | Backup server ID provide if backup is there on remote server | No |
dir | POST | text | The directory where the backup image has been saved | Yes |
date | POST | Int | The date at which the backup was taken should be in the format YYYYMMDD | Yes |
newvps | POST | 1/0 | If set a new VPS will be created using the backup file | No |
newserid | POST | Int | Pass serid on which you want to restore the backup (by default it will restore on same server where the vpsid exists) | No |
file | POST | text | Provide file name which you want to restore (If file name is not provided than latest file in file list will be resotred) | Yes since 3.0.6.3 |
Sample Code
<?php
require_once('/usr/local/virtualizor/sdk/admin.php');
$key = 'your_api_key'; //key of server on which vps is present.
$pass = 'your_api_pass'; //pass of server on which vps is present.
$ip = 'your_server_ip'; //ip of server on which vps is present.
$admin = new Virtualizor_Admin_API($ip, $key, $pass);
$post = array();
$post['vpsid'] = 79 ;
$post['dir'] = '/tmp/api_backup' ;
$post['date'] = 20180918 ;
$post['file'] = '807_test_2021_07_09-10_40_10.tar.gz'; //since 3.0.6.3
$post['newvps'] = 1 ; // Pass this if you want to restore to a new vps
$output = $admin->vpsrestore($post);
print_r(json_encode($output));
?>
Output
{
"title": "Restore VPS Backups",
"restore_done": true,
"restore_details": "",
"timenow": 1537294345,
"time_taken": "0.244"
}