API Set VPS Backup Setting

From Virtualizor Wiki
Jump to: navigation, search
NOTE
This is OLD API Documentation. Click on the following link for New API Documentation
Admin API

Set VPS Backup Settings

Parameters Type Description
vpsbackups POST Flag to set a Backup Settings(This has to be 1)
type POST Backup Type (LOCAL, SSH, FTP)
id POST ID of Backup Server if type other than LOCAL
enabled POST Set as 1 to enable VPS Backups
newvps POST Set as 1 to enable Backup for newly created VPS
dir POST The directory where Backups will be stored
freq POST Backup Frequency (hourly, daily, weekly, monthly)
date POST Backup month date (1 - 31)
hourly_freq POST Backup hour (00 - 23)
day POST Backup day (1 - 7)
hrs POST Backup hourly time
min POST Backup minute time
rotation POST Number of Backups allowed at a time
nice POST CPU priority for backup process (-20 most favourble to 19 least favourable)
ionice_prio POST IO priority for the backup process (0 - 7)
ionice_class POST IO class for the backup process. (1 - Real Time, 2 - Best Effort, 3- Idle)
compression POST Set as 1 to disable compression for backups
vpses POST VPS ID as array for backups
backupnow POST Set as 1 to start an immediate backup as per previously saved settings
clearlog POST Set as 1 to clear Backup logs

Example Code

<?php

    require_once('admin.php');

    $key =  'uketenhrhpunty5lhgwkcuxxxxxxxxxx';

    $pass = 'yrsofc3tg3tre7bjpfppspxxxxxxxxxx';

    $ip = 'xxx.xxx.xxx.xxx';

    $admin = new Virtualizor_Admin_API($ip, $key, $pass);

    $post = array();
    $post['vpsbackups'] = 1;
    $post['type'] = 'LOCAL';
    $post['enabled'] = 1;
    $post['dir'] = '/test';
    $post['freq'] = 'monthly'; // takes value hourly, daily, weekly, monthly
    $post['date'] = 1; // if freq set as monthly (1 - 31)
    $post['hourly_freq'] = '00'; // if freq set as hourly (00 - 23)
    $post['hrs'] = '00';
    $post['min'] = '00';
    $post['rotation'] = 1;
    $post['nice'] = '-20'; // process priority (-20 - 19)
    $post['ionice_prio'] = '0'; // IO priority(0 - 7)
    $post['ionice_class'] = '1'; // IO class (1 - 3)
    $post['vpses'][] = '1415';
    
    $output = $admin->vpsbackupsettings($post);
    print_r($output);
?>

Returns: <syntaxhighlight lang="php"> Array (

   [title] => VPS Backups Settings
   [done] => 1
   [backupsettings] => Array
       (
           [vbid] => 166
           [serid] => 0
           [bid] => 0
           [enabled] => 1
           [newvps] => 0
           [frequency] => monthly
           [run_time] => 00:00
           [hourly_freq] => 00
           [run_day] => 
           [run_date] => 1
           [rotation] => 1
           [vpsids] => Array
               (
                   [0] => 1415
               )
           [nice] => -20
           [ionice_prio] => 0
           [ionice_class] => 1
           [disable_compression] => 0
           [dir] => /test
           [use_ppk] => 
           [hrs] => 00
           [min] => 00
       )
   [timenow] => 1441192383
   [time_taken] => 0.079

)