Beispiel #1
0
 private function prepareUploadToStorages()
 {
     $uploadToStorages = SGConfig::get('SG_BACKUP_UPLOAD_TO_STORAGES');
     if (SGBoot::isFeatureAvailable('STORAGE') && $uploadToStorages) {
         $storages = explode(',', $uploadToStorages);
         $arr = array();
         foreach ($storages as $storageId) {
             $actionId = SGBackupStorage::queueBackupForUpload($this->fileName, $storageId);
             $arr[] = $actionId;
         }
         $this->queuedStorageUploads = $arr;
     }
 }
Beispiel #2
0
 private function prepareForBackup()
 {
     //start logging
     SGBackupLog::writeAction('backup', SG_BACKUP_LOG_POS_START);
     //save timestamp for future use
     $this->actionStartTs = time();
     //create action inside db
     $status = $this->databaseBackupAvailable ? SG_ACTION_STATUS_IN_PROGRESS_DB : SG_ACTION_STATUS_IN_PROGRESS_FILES;
     $this->actionId = self::createAction($this->fileName, SG_ACTION_TYPE_BACKUP, $status);
     //set paths
     $this->filesBackupPath = SG_BACKUP_DIRECTORY . $this->fileName . '/' . $this->fileName . '.sgbp';
     $this->databaseBackupPath = SG_BACKUP_DIRECTORY . $this->fileName . '/' . $this->fileName . '.sql';
     //prepare sgbp file
     @file_put_contents($this->filesBackupPath, '');
     if (!is_writable($this->filesBackupPath)) {
         throw new SGExceptionForbidden('Could not create backup file: ' . $filePath);
     }
     $this->backupFiles->setFilePath($this->filesBackupPath);
     SGConfig::set('SG_RUNNING_ACTION', 1, true);
     //check if upload to storages is needed
     $uploadToStorages = SGConfig::get('SG_BACKUP_UPLOAD_TO_STORAGES');
     if (SGBoot::isFeatureAvailable('STORAGE') && $uploadToStorages) {
         $storages = explode(',', $uploadToStorages);
         $arr = array();
         foreach ($storages as $storageId) {
             $actionId = SGBackupStorage::queueBackupForUpload($this->fileName, $storageId);
             $arr[] = $actionId;
         }
         $this->queuedStorageUploads = $arr;
     }
     //register shutdown function (used for handling execution time limits)
     register_shutdown_function('shutdownAction', $this->actionId, SG_ACTION_TYPE_BACKUP, $this->filesBackupPath, $this->databaseBackupPath);
 }