Esempio n. 1
0
 static function sharedInstance()
 {
     if (is_null(self::$sharedInstance)) {
         self::$sharedInstance = new self();
     }
     return self::$sharedInstance;
 }
Esempio n. 2
0
function curlBackup($params)
{
    $id = (int) $params['id'];
    $backup = Backup::sharedInstance();
    $modelJob = ModelJob::sharedInstance();
    ini_set("max_execution_time", 0);
    $jobConf = ModelJobConf::sharedInstance()->findById($id)[0];
    $db = ModelDb::sharedInstance()->findById((int) $jobConf->dbId)[0];
    $path = ModelPath::sharedInstance()->findById((int) $jobConf->pathId)[0];
    if (!is_null($jobConf)) {
        $job = new EntityJob();
        $job->jobConfId = $jobConf->id;
        $job->jobConfName = $jobConf->name;
        $job->starttime = time();
        $job->status = "file";
        $job->uploaded = 0;
        $job->deleted = 0;
        $modelJob->save($job);
        // update job status to "file" and save()
        $filename = $backup->backupFiles($path->path, $path->ignored);
        $job->filename = $filename;
        // update job status to "db" and save()
        $job->status = "db";
        $modelJob->save($job);
        $dbfilename = $backup->backupDatabase($db->host, $db->username, $db->pass, $db->dbname);
        $job->dbfilename = $dbfilename;
        // update job status to "cleanup" and save()
        $job->status = "files";
        $modelJob->save($job);
        //$backup->deleteBackups(); //TODO: implement a counter int he config and delete old backups when necessary
        $job->status = "done";
        $job->endtime = time();
        $modelJob->save($job);
        echo "<br/>All done\n";
        //update job status to "complete" or "error" and save()
    }
    exit;
}
Esempio n. 3
0
function delete($params)
{
    $id = $params['id'];
    ModelPath::sharedInstance()->deleteById($id);
    ModelJobConf::sharedInstance()->deleteAssociatedJob($id, 'path');
}