$logger->log('Scheduled Cleanup requested'); $logger->log('**CLEAN UNFINISHED BACKUPS**'); //cleanup any folders that have the TMP_ prefix $wp_backup->cleanup_backups_by_prefix('TMP_'); $logger->log('**END CLEAN UNFINISHED BACKUPS**'); $logger->log('**CLEAN DELETED BACKUPS**'); //cleanup any folders that have the DLT_ prefix $wp_backup->cleanup_backups_by_prefix('DLT_'); $logger->log('**END CLEAN DELETED BACKUPS**'); $logger->log('**CLEAN OLD BACKUPS**'); //Cleanup any folders that exceed retention limit $wp_backup->cleanup_old_backups(); $logger->log('**END CLEAN OLD BACKUPS**'); $logger->log('**CLEAN OLD RESTORES**'); //Cleanup any folders that exceed retention limit $wp_restore = new WPBackItUp_Restore($logger, $job_name, null); $wp_restore->delete_restore_folder(); $logger->log('**END CLEAN OLD RESTORES**'); $logger->log('**PURGE OLD FILES**'); $wp_backup->purge_old_files(); $logger->log('**END PURGE OLD FILES**'); $logger->log('**SECURE FOLDERS**'); //Make sure backup folder is secured $file_system = new WPBackItUp_FileSystem(); //Make sure backup folder is secured $backup_dir = WPBACKITUP__CONTENT_PATH . '/' . WPBACKITUP__BACKUP_FOLDER; $file_system->secure_folder($backup_dir); //--Check restore folder folders $restore_dir = WPBACKITUP__CONTENT_PATH . '/' . WPBACKITUP__RESTORE_FOLDER; $file_system->secure_folder($restore_dir); //Make sure logs folder is secured
$backup_name = $restore_job->get_job_meta('backup_name'); if (empty($backup_name)) { $logger->log_error(__METHOD__, 'Backup name not found in job meta.'); write_fatal_error_status('error201'); end_restore(); } //Get user ID $user_id = $restore_job->get_job_meta('user_id'); if (empty($user_id)) { $logger->log_error(__METHOD__, 'User Id not found in job meta.'); write_fatal_error_status('error201'); end_restore(); } global $wp_restore; //Eventually everything will be migrated to this class $wp_restore = new WPBackItUp_Restore($logger, $backup_name, $restore_job->get_job_id()); //*************************// //*** RESTORE TASKS ***// //*************************// //An error has occurred on the previous tasks if ($restore_error) { //Check for error type switch ($current_task->getId()) { case "task_preparing": fatal_error('preparing', '2001', 'Task ended in error:' . $current_task->getId()); break; case "task_unzip_backup_set": fatal_error('unzipping', '2002', 'Task ended in error:' . $current_task->getId()); break; case "task_validate_backup": fatal_error('validation', '2003', 'Task ended in error:' . $current_task->getId());