Method to initiate manual backup via API or similar

Discussion in 'General' started by variable99, Aug 31, 2024.

  1. variable99

    variable99 Member HowtoForge Supporter

    I'am looking way to trigger manual file and sql backup. Main goal: to create flexible, user defined backup schedule in my own system.
    Is it enough if I insert manually command into table "sys_remoteaction"? Like this:

    [​IMG]

    With action_state "pending".
     
  2. till

    till Super Moderator Staff Member ISPConfig Developer

    I guess the action you posted is a backup download, not the creation of a backup. Create a backup manually and see which kind of action gets used then. You can try if its sufficient to add it in a similar way into that table.
     
  3. variable99

    variable99 Member HowtoForge Supporter

    I found this function in /usr/local/ispconfig/interface/lib/classes/plugin_backuplist.inc.php :
    PHP:
    protected function makeBackup(&$message, &$error$wb)
        {
            global 
    $app;

            
    $mode $_GET['make_backup'];
            
    $action_type = ($mode == 'web') ? 'backup_web_files' 'backup_database';
            
    $domain_id intval($this->form->id);

            
    $sql "SELECT count(action_id) as number FROM sys_remoteaction WHERE action_state = 'pending' AND action_type = ? AND action_param = ?";
            
    $tmp $app->db->queryOneRecord($sql$action_type$domain_id);
            if (
    $tmp['number'] == 0) {
                if(
    $action_type === 'backup_database') {
                    
    // get all server ids of databases for this domain
                    
    $sql 'SELECT DISTINCT `server_id` FROM `web_database` WHERE `parent_domain_id` = ?';
                    
    $result $app->db->query($sql$domain_id);
                    while((
    $cur $result->get())) {
                        
    $server_id $cur['server_id'];
                        
    $sql "INSERT INTO sys_remoteaction (server_id, tstamp, action_type, action_param, action_state, response) VALUES (?, UNIX_TIMESTAMP(), ?, ?, 'pending', '')";
                        
    $app->db->query($sql$server_id$action_type$domain_id);
                    }
                    
    $result->free();
                } else {
                    
    $server_id $this->form->dataRecord['server_id'];
                    
    $sql "INSERT INTO sys_remoteaction (server_id, tstamp, action_type, action_param, action_state, response) VALUES (?, UNIX_TIMESTAMP(), ?, ?, 'pending', '')";
                    
    $app->db->query($sql$server_id$action_type$domain_id);
                }
                
    $message .= $wb['backup_info_txt'];
            } else {
                
    $error .= $wb['backup_pending_txt'];
            }
        }
    That's why I brought this idea of manually inserting entries into the table. I will try my idea and report back.
     
    ahrasis and till like this.

Share This Page