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
Name | Method | Value | Description | Required |
---|---|---|---|---|
act | GET | databackups | The action will set the backup settings | Yes |
databasebackups | POST | 1/0 | If set then the database backups will be taken | Yes |
type | POST | text | The type of backups to be taken ( values can be EMAIL, SSH, FTP) | Yes |
dbbackup_cron | POST | dbbackup_cron | The cron will be set to take timely backup of database | Yes |
POST | The email to which the backup will be sent | No | ||
dbbackup_server | POST | Int | The ID of the backup server, required for types SSH and FTP | Yes |
dbbackup_server_dir | POST | text | The directory of the remote on which backup file will be saved, required for types SSH and FTP | Yes |
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"
}