Create VPS Backup

Use the Create VPS Backup API to create the backup of the VPS. This is the image of the VPS which can be stored locally or remotely depending on the backup plan given to the VPS. The log file for the backup process can be found at /var/virtualizor/log/backup/VPSID.log. The API response will contain “done” as “1” after the backup process is started successfully.

For more information, you can refer this Backup Plans guide.

HTTP Request

https://hostname:4085/index.php?act=editbackup_plan

Parameters

NameMethodValueDescriptionRequired
actGETeditbackup_planThe action will return done as 1 after the backup is successfulYes
backup_nowPOST1The value should be set to one for taking backup of the VPS that belong to this backup planYes
bpidPOSTIntThe backup plan ID that has been given to the VPSYes

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['backup_now'] = 1;
    $post['bpid'] = 3;

    $output = $admin->createvpsbackup($post);

    print_r(json_encode($output));
?>

Output

{
    "title": "Edit Backup Plan",
    "done": 1,
    "backup_plan": {
        "bpid": "3",
        "disabled": "0",
        "plan_name": "api backup",
        "bid": "0",
        "frequency": "hourly",
        "run_time": "00:00",
        "hourly_freq": "1",
        "run_day": "1",
        "run_date": "1",
        "rotation": "1",
        "backup_limit": "0",
        "restore_limit": "0",
        "enable_enduser_backup_servers": "0",
        "nice": "0",
        "ionice_prio": "0",
        "ionice_class": "3",
        "disable_compression": "1",
        "dir": "/tmp/api_backup"
    },
    "vpses": {
        "79": {
            "vpsid": "79",
            "vps_name": "v1002",
            "serid": "0",
            "hostname": "www.mydomainpp.com",
            "space": "2"
        }
    },
    "timenow": 1537290773,
    "time_taken": "0.269"
}
Was this helpful to you?