Get Virtualizor

Create Database Backup

Use the Create Database Backup API to create the database backup file. These are compressed files of the master server's MySQL database. These files are stored at the /var/virtualizor directory. The API response will contain "done" with message "true" on successful creation of the backup file.

This feature is only available for the Master Server database. Please do not restore the Database if its for an older version. It will cause Virtualizor to malfunction.

See also, Database Backup Guide

HTTP Request

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

Parameters

NameMethodValueDescriptionRequired
actGETdatabackupThe action will return succ as true on successYes
dbdownPOST1The value should be set to 1 for creating the database backup fileYes

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['dbdown'] = 1 ;

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

    print_r(json_encode($output));
?>

Output

{
    "title": "Database Backup",
    "done": {
        "succ": true
    },
    "filename": {
        "2": "virtualizor-2018-09-18_16.33.18.sql.gz",
        "3": "virtualizor-2018-09-18_17.23.28.sql.gz",
        "4": "virtualizor-2018-09-18_17.29.19.sql.gz",
        "5": "virtualizor-2018-09-18_17.37.15.sql.gz"
    },
    "backup_servers": {
        "1": {
            "bid": "1",
            "name": "slate_doc_server",
            "type": "SSH"
        }
    },
    "timenow": 1537288640,
    "time_taken": "0.223"
}
    Was this page helpful?
    Newsletter Subscription
    Subscribing you to the mailing list