Backup plans enable you to create different VPS backup settings for different VPS on the same server(s). You can assign backup plans to individual VPS or to the entire VPS plan. You can also allow the endusers to initiate backup/restore of their VPS at their will in the backup plan. Use the Add Backup Plans API to create a backup plan on the Virtualizor panel. The API response will contain "done" as "1" on successful creation of the backup plan.
For more information, you can refer this Backup Plans guide.
HTTP Request
https://hostname:4085/index.php?act=addbackup_plan
Parameters
Name | Method | Value | Description | Required |
---|---|---|---|---|
act | GET | addbackup_plan | The action specified to perform operation and will return "done" as "1" on successful creation of the backup plan | Yes |
disabled | POST | 1/0 | If set this backup plan will be disabled | No |
plan_name | POST | text | The name of the backup plan | Yes |
type | POST | text | The backup type valid values are 'LOCAL', 'FTP' and 'SSH' | Yes |
id | POST | Int | ID of the backup server required if backup type is SSH or FTP | No |
dir | POST | text | The path of the directory where backups will be stored | Yes |
freq | POST | text | Backup Frequency valid values are 'hourly', 'daily', 'weekly' and 'monthly' | Yes |
hourly_freq | POST | Int | The hourly backup frequency valid values (0-23) | Yes |
hrs | POST | Int | The hour at which the backup will begin values are (0-23) | Yes |
min | POST | Int | The minute at which the backup will begin values are (0-59) | Yes |
day | POST | Int | The day of the week when the backup will begin valid values are(1 for Monday to 7 for Sunday) | Yes |
date | POST | Int | The date at which backup will begin valid values are (1-31) | Yes |
rotation | POST | Int | Number of backup per VPS allowed (0-10), 0 for unlimited | Yes |
backup_limit | POST | Int | Max number of manual backup operations the VPS user can perform per month valid values are (-1 to 10), -1 for unlimited and 0 for disabled | Yes |
restore_limit | POST | Int | Max number of restore operations the VPS user can perform per month valid values are (-1 to 10), -1 for unlimited and 0 for disabled | Yes |
nice | POST | Int | CPU time the backup process will get. 19 (least favourable) to -20 (most favourable) | Yes |
ionice_prio | POST | Int | IO priority for the backup process valid values are (0-7) | Yes |
ionice_class | POST | Int | IO class for the backup process valid values (1 for Real time, 2 for Best Effort, 3 for Idle ) | Yes |
compression | POST | 1/0 | Disable compression for the backups. This will take effect only for KVM, Xen-HVM and OpenVZ | 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['type'] = 'LOCAL' ;
$post['plan_name'] = 'api backup' ;
$post['id'] = 1 ;
$post['dir'] = '/tmp/api_backup/' ;
$post['freq'] = 'hourly' ;
$post['hourly_freq'] = 1 ;
$post['hrs'] = 0 ;
$post['min'] = 0 ;
$post['day'] = 1 ;
$post['date'] = 1 ;
$post['rotation'] = 1 ;
$post['backup_limit'] = 0 ;
$post['restore_limit'] = 0 ;
$post['nice'] = 0 ;
$post['ionice_prio'] = 0 ;
$post['ionice_class'] = 3 ;
$post['compression'] = 1 ;
$output = $admin->addbackupplan($post);
print_r(json_encode($output));
?>
Output
{
"title": "Add Backup Plan",
"done": 343, //backup plan ID
"timenow": 1536952659,
"time_taken": "0.213"
}