Get Virtualizor

Restore VPS Backups

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

NameMethodValueDescriptionRequired
actGET vpsrestore This action will restore the vps whose backup exists and return restore_done as trueYes
vpsidPOSTIntThe ID of vps which needs to be restoredYes
bidPOSTIntBackup server ID provide if backup is there on remote serverNo
dirPOSTtextThe directory where the backup image has been savedYes
datePOSTIntThe date at which the backup was taken should be in the format YYYYMMDDYes
newvpsPOST1/0If set a new VPS will be created using the backup fileNo
newseridPOSTIntPass serid on which you want to restore the backup (by default it will restore on same server where the vpsid exists)No
filePOSTtextProvide 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"
}
    Was this page helpful?
    Newsletter Subscription
    Subscribing you to the mailing list