Use the Migrate VPS API to migrate the VPS(s) present on master server to your slave server. You can select the storage disk on which migration of the VPS will take place, for migration single VPS.
For migration of multiple VPSes do not pass the storage ID of the
destination server as virtualizor automatically chooses the storage disk
on which the migration will take place.
The API response will contain "actid" which can be used to monitor the migration process at admin panel or using the Task API.
It is recommended that you save the VPS data before starting this process as Virtualizor will power off the VPS to do the transfer.
For more information, you can refer this GUI Migration Guide.
HTTP Request
https://hostname:4085/index.php?act=migrate
Parameters
Name | Method | Value | Description | Required |
---|---|---|---|---|
act | GET | migrate | The action specified to carry out operation and return data after vps has been migrated | Yes |
vpsid | POST | array | The array of vpsid that need to be migrated | Yes |
storage | POST | array | The array of storage ID of the slave | Yes |
from_server | POST | Int | The server ID from which the vps needs to be migrated | No |
from_ip | POST | text | The server ip from which vps needs to be migrated | Yes |
from_pass | POST | text | The server password from which the vps needs to be migrated | Yes |
migrate | POST | Int | If set to 1, then the vps migration process will begin | Yes |
migrate_but | POST | Int | If set to 1 the migration process will begin | Yes |
speed_limit | POST | Int | Setting a speed limit for vps migration in Mb/s | No |
to_server | POST | Int | The server ID to which the vps will be migrated | No |
preserve_ip | POST | 1/0 | Set this option to use same IP Address(s) on the migrated VPS | No |
del_orig | POST | 1/0 | Set this option to delete the source VPS after successful Migration | No |
ignore_if_vdfconflict | POST | 1/0 | If set, the HAProxy VPS Domain Forwarding records will be ignored, if a conflict is found with records on the destination server | Yes |
disable_gzip | POST | 1/0 | If checked, compression (i.e. gzip) will not be used during migration | Yes |
live_mig | POST | 1/0 | If sent, Live migration will be attempted | No |
Sample Code
<?php
require_once('/usr/local/virtualizor/sdk/admin.php');
$key = 'your_api_key';
$pass = 'your_api_pass';
$ip = 'your_server_ip';
$admin = new Virtualizor_Admin_API($ip, $key, $pass);
$post = array();
$post['from_ip'] = 0;
$post['from_server'] = 0;
$post['speed_limit'] = 100;
$post['to_server'] = 1;
$post['migrate'] = 1;
$post['migrate_but'] = 1;
$post['vpsid'] = array(3801);
$post['storage'] = array(279);
$output = $admin->migrate($post);
print_r(json_encode($output));
?>
Output
{
"title": "KVMTestServer",
"actid": "4902",
"timenow": 1481700829,
"time_taken": "6.139"
}