Get Virtualizor

Database Backups

Use the Database Backups API to take backup of database at regular intervals. The backups contains of the zipped files of the master server database. You can choose to take the backups on your backup server or email the backup file to the specified email address. The API response will contain "done" as "1" after the cron job is successfully set.

The Scheduled Database Backup utility 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.

HTTP Request

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

Parameters

NameMethodValueDescriptionRequired
actGETdatabackupsThe action will set the backup settingsYes
databasebackupsPOST1/0If set then the database backups will be takenYes
typePOSTtextThe type of backups to be taken ( values can be EMAIL, SSH, FTP)Yes
dbbackup_cronPOSTdbbackup_cronThe cron will be set to take timely backup of databaseYes
emailPOSTemailThe email to which the backup will be sentNo
dbbackup_serverPOSTIntThe ID of the backup server, required for types SSH and FTPYes
dbbackup_server_dirPOSTtextThe directory of the remote on which backup file will be saved, required for types SSH and FTPYes

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['databasebackups'] = 1;
    $post['type'] = 'EMAIL';
    $post['dbbackup_cron'] = '18 16 * *3';
    $post['email'] = 'test@test.com';

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

    print_r(json_encode($output));
?>

Output

{
    "title": "Database Backup",
    "done": {
        "cron_set": 1
    },
    "backup_servers": {
        "1": {
            "bid": "1",
            "name": "slate_doc_server",
            "type": "SSH"
        }
    },
    "timenow": 1536255440,
    "time_taken": "0.214"
}
    Was this page helpful?
    Newsletter Subscription
    Subscribing you to the mailing list