public static function draw()
    {
        ?>
            <span class="menu-title">Configure schedule <?php 
        echo SNS_PRO_TOOLTIP;
        ?>
</span>
            <div class="tab-content">
                <form role="form" autocomplete="off" class="schedule-form" action="">
                    <div class="form-group">
                        <label class="checkbox-inline">
                            <input type="checkbox" value="" disabled="disabled">Enable
                        </label>
                    </div>

                    <label>How often you want to backup?</label>
                    <div class="periodicity-block">
                        <div class="form-group">
                            <label class="radio">
                                <input type="radio" disabled="disabled">Each hour
                            </label>
                        </div>
                        <div class="form-group">
                            <label class="radio">
                                <input type="radio" disabled="disabled">Each day
                            </label>
                        </div>
                        <div class="form-group">
                            <label class="radio">
                                <input type="radio" disabled="disabled">Each week
                            </label>
                        </div>
                        <div class="form-group">
                            <label class="radio">
                                <input type="radio" disabled="disabled">Each month
                            </label>
                        </div>
                    </div>
                    <div class="separator"></div>
                    <label>Where you want to save your backup?</label>
                    <?php 
        $destination = new Sns_Destination(Sns_Backup::BACKUP_MODE_SCHEDULE);
        $destination->draw();
        ?>
                    <div class="separator"></div>
                    <button type="submit" class="btn btn-primary sns-action disabled">Save</button>
                </form>
            </div>
        <?php 
    }
function sns_configure_backup_db_data()
{
    global $wpdb;
    $table_name = SNS_DB_PREFIX . 'options';
    $options = $wpdb->get_results("SELECT COUNT(*) as `cnt` FROM {$table_name}", ARRAY_A);
    if ($options[0]['cnt'] == 0) {
        foreach (Sns_Option::get_options_list() as $option) {
            if ($option == Sns_Option::COUNT) {
                $val = intval(SNS_BACKUPS_MAX_COUNT);
            } else {
                $val = intval(Sns_Option::SET);
            }
            $wpdb->insert($table_name, array('option' => $option, 'value' => $val));
        }
    }
    $table_name = SNS_DB_PREFIX . 'settings_destinations';
    $destinations = $wpdb->get_results("SELECT COUNT(*) as `cnt` FROM {$table_name}", ARRAY_A);
    if ($destinations[0]['cnt'] == 0) {
        foreach (Sns_Destination::get_destinations_list() as $destination) {
            $wpdb->insert($table_name, array('name' => $destination));
        }
    }
    $table_name = SNS_DB_PREFIX . 'settings_ftp';
    $ftp = $wpdb->get_results("SELECT COUNT(*) as `cnt` FROM {$table_name}", ARRAY_A);
    if ($ftp[0]['cnt'] == 0) {
        $wpdb->insert($table_name, array('server' => '', 'port' => SNS_FTP_DEF_PORT));
    }
    $table_name = SNS_DB_PREFIX . 'state';
    $state = $wpdb->get_results("SELECT `status` FROM {$table_name}", ARRAY_A);
    if (empty($state)) {
        $wpdb->insert($table_name, array('type' => Sns_State::TYPE_BACKUP, 'status' => Sns_State::STATUS_NONE));
    } else {
        $data = array('status' => Sns_State::STATUS_NONE);
        Sns_State::update($data);
    }
}
 public function save()
 {
     global $wpdb;
     $table_name = SNS_DB_PREFIX . 'backups';
     $options = Sns_Option::get_options(true);
     $option_list = array();
     foreach ($options as $option => $data) {
         if ($option == Sns_Option::FULL) {
             $option_list = array($option);
             break;
         }
         if ($option != Sns_Option::COUNT) {
             $option_list[] = $option;
         }
     }
     $destination = new Sns_Destination($this->type);
     $destinations = $destination->get_destinations();
     $destination_list = array();
     foreach ($destinations as $name => $dst) {
         if ($dst->status == Sns_Destination::SET) {
             $destination_list[] = $name;
         }
     }
     $info = json_encode(array('options' => $option_list, 'destinations' => $destination_list));
     $data = array('type' => $this->type, 'info' => $info, 'backup_date' => date('Y-m-d H:i:s'), 'hash' => $this->hash, 'filename' => $this->filename);
     $r = $wpdb->insert($table_name, $data);
     if ($r === false) {
         throw new Sns_Exception_DB_Error('Error on inserting into ' . $table_name . ' data: ' . json_encode($data));
     }
 }
            <div id="menu-tabs" class="menu-block">
                <div class="menu-container">
                    <ul>
                        <li class="menu-item"><a href="#menu-tab-manual">Manual backup</a></li>
                        <li class="menu-item"><a href="#menu-tab-history">Backup history & restore</a></li>
                        <li class="menu-item"><a href="#menu-tab-schedule">Schedule</a></li>
                        <li class="menu-item"><a href="#menu-tab-settings">Settings</a></li>
                    </ul>
                </div>
                <div class="content-block">
                    <div id="menu-tab-manual">
                        <span class="menu-title">Backup destination</span>
                        <div class="menu-content">
                            <form class="manual-form" autocomplete="off" role="form" action="">
                                <?php 
$destination = new Sns_Destination(Sns_Backup::BACKUP_MODE_MANUAL);
$destination->draw();
?>
                                <div class="separator"></div>
                                <div class="cb"></div>
                                <div id="progressbar-backup"><div class="progress-label"></div></div>

                                <button type="submit" class="btn btn-primary sns-action">Backup</button>
                            </form>
                        </div>
                    </div>
                    <div id="menu-tab-history">
                        <?php 
Sns_History::draw();
?>
                    </div>
function sns_backup_manual_backup()
{
    @set_time_limit(0);
    register_shutdown_function('sns_register_shutdown');
    try {
        Sns_Log::log_msg('########PROCESS STARTED########' . PHP_EOL);
        $state = Sns_State::get_status();
        if ($state['status'] == Sns_State::STATUS_ACTIVE) {
            throw new Sns_Exception_Unavailable_Operation('There is an existing active process.Please wait.');
        }
        $stateData = array('status' => Sns_State::STATUS_ACTIVE, 'type' => Sns_State::TYPE_BACKUP, 'start_date' => date('Y-m-d H:i:s'));
        Sns_State::update($stateData);
        Sns_Checker::check();
        $locations = isset($_POST['locations']) ? $_POST['locations'] : array();
        $destination = new Sns_Destination(Sns_Backup::BACKUP_MODE_MANUAL);
        $destination->set_destinations($locations);
        $destination->save();
        $backup = new Sns_Backup(Sns_Backup::BACKUP_MODE_MANUAL);
        Sns_State::$currentBackupFilename = $backup->getFilename();
        $dest = 'local';
        if (count($locations)) {
            $dest .= ',' . implode(',', array_keys($locations));
        }
        $options = Sns_Option::get_options(true);
        foreach ($options as $option => $data) {
            if ($option == Sns_Option::FULL) {
                $option_list = array($option);
                break;
            }
            if ($option != Sns_Option::COUNT) {
                $option_list[] = $option;
            }
        }
        $options = implode(',', array_values($option_list));
        $engLogDecription = '----------------------------------------------------';
        $engLogDecription .= "\n" . ucfirst($stateData['type']) . ": " . $options;
        $engLogDecription .= "\nDestination: " . $dest . "\n";
        $engLogDecription .= "----------------------------------------------------\n";
        Sns_Log::log_msg($engLogDecription);
        Sns_Log::log_action('Backing up');
        $warns = $backup->backup();
        Sns_Log::log_action('Backing up', SNS_LOG_END);
        Sns_Log::log_msg("\n");
        $skipped_files = '';
        if (!empty($warns['not_readable'])) {
            $skipped_files .= '*********WARNING**********' . PHP_EOL;
            $skipped_files .= 'The following files are not readable and were excluded from backup package' . PHP_EOL;
            $i = 1;
            foreach ($warns['not_readable'] as $file) {
                $skipped_files .= $i . '. ' . $file . PHP_EOL;
                $i++;
            }
            Sns_Log::log_msg($skipped_files);
        }
        $stateData = array('status' => Sns_State::STATUS_FINISHED, 'type' => Sns_State::TYPE_BACKUP);
        Sns_State::update($stateData);
        Sns_Log::log_msg('########PROCESS ENDED########' . PHP_EOL);
    } catch (Exception $e) {
        Sns_Log::log_exception_obj($e);
        $ex_data = Sns_Exception_Handler::get_exception_data($e);
        $stateData = array('status' => Sns_State::STATUS_FAILED, 'type' => Sns_State::TYPE_BACKUP, 'msg' => $ex_data['status'] . ' : ' . $ex_data['msg']);
        Sns_State::update($stateData);
        Sns_Log::log_msg('########PROCESS ENDED########' . PHP_EOL);
        Sns_Log::report('backup');
    }
    die;
}