How to use backup class

Best Phoronix-test-suite code snippet using backup

backup_includes.php

Source:backup_includes.php Github

copy

Full Screen

...14// You should have received a copy of the GNU General Public License15// along with Moodle. If not, see <http://www.gnu.org/licenses/>.16/**17 * @package moodlecore18 * @subpackage backup-includes19 * @copyright 2010 onwards Eloy Lafuente (stronk7) {@link http://stronk7.com}20 * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later21 */22// Prevent direct access to this file23if (!defined('MOODLE_INTERNAL')) {24 die('Direct access to this script is forbidden.');25}26// Include all the backup needed stuff27require_once($CFG->dirroot . '/backup/util/interfaces/checksumable.class.php');28require_once($CFG->dirroot . '/backup/util/interfaces/executable.class.php');29require_once($CFG->dirroot . '/backup/util/interfaces/processable.class.php');30require_once($CFG->dirroot . '/backup/util/interfaces/annotable.class.php');31require_once($CFG->dirroot . '/backup/util/interfaces/loggable.class.php');32require_once($CFG->dirroot . '/backup/backup.class.php');33require_once($CFG->dirroot . '/backup/util/output/output_controller.class.php');34require_once($CFG->dirroot . '/backup/util/factories/backup_factory.class.php');35require_once($CFG->dirroot . '/backup/util/dbops/backup_dbops.class.php');36require_once($CFG->dirroot . '/backup/util/dbops/backup_structure_dbops.class.php');37require_once($CFG->dirroot . '/backup/util/dbops/backup_controller_dbops.class.php');38require_once($CFG->dirroot . '/backup/util/dbops/backup_plan_dbops.class.php');39require_once($CFG->dirroot . '/backup/util/dbops/backup_question_dbops.class.php');40require_once($CFG->dirroot . '/backup/util/checks/backup_check.class.php');41require_once($CFG->dirroot . '/backup/util/structure/base_atom.class.php');42require_once($CFG->dirroot . '/backup/util/structure/base_attribute.class.php');43require_once($CFG->dirroot . '/backup/util/structure/base_final_element.class.php');44require_once($CFG->dirroot . '/backup/util/structure/base_nested_element.class.php');45require_once($CFG->dirroot . '/backup/util/structure/base_optigroup.class.php');46require_once($CFG->dirroot . '/backup/util/structure/base_processor.class.php');47require_once($CFG->dirroot . '/backup/util/structure/backup_attribute.class.php');48require_once($CFG->dirroot . '/backup/util/structure/backup_final_element.class.php');49require_once($CFG->dirroot . '/backup/util/structure/backup_nested_element.class.php');50require_once($CFG->dirroot . '/backup/util/structure/backup_optigroup.class.php');51require_once($CFG->dirroot . '/backup/util/structure/backup_optigroup_element.class.php');52require_once($CFG->dirroot . '/backup/util/structure/backup_structure_processor.class.php');53require_once($CFG->dirroot . '/backup/util/helper/backup_helper.class.php');54require_once($CFG->dirroot . '/backup/util/helper/backup_general_helper.class.php');55require_once($CFG->dirroot . '/backup/util/helper/backup_null_iterator.class.php');56require_once($CFG->dirroot . '/backup/util/helper/backup_array_iterator.class.php');57require_once($CFG->dirroot . '/backup/util/helper/backup_anonymizer_helper.class.php');58require_once($CFG->dirroot . '/backup/util/helper/backup_file_manager.class.php');59require_once($CFG->dirroot . '/backup/util/helper/restore_moodlexml_parser_processor.class.php'); // Required by backup_general_helper::get_backup_information().60require_once($CFG->dirroot . '/backup/util/xml/xml_writer.class.php');61require_once($CFG->dirroot . '/backup/util/xml/output/xml_output.class.php');62require_once($CFG->dirroot . '/backup/util/xml/output/file_xml_output.class.php');63require_once($CFG->dirroot . '/backup/util/xml/contenttransformer/xml_contenttransformer.class.php');64require_once($CFG->dirroot . '/backup/util/xml/parser/progressive_parser.class.php');65require_once($CFG->dirroot . '/backup/util/loggers/base_logger.class.php');66require_once($CFG->dirroot . '/backup/util/loggers/error_log_logger.class.php');67require_once($CFG->dirroot . '/backup/util/loggers/file_logger.class.php');68require_once($CFG->dirroot . '/backup/util/loggers/core_backup_html_logger.class.php');69require_once($CFG->dirroot . '/backup/util/loggers/database_logger.class.php');70require_once($CFG->dirroot . '/backup/util/loggers/output_indented_logger.class.php');71require_once($CFG->dirroot . '/backup/util/settings/setting_dependency.class.php');72require_once($CFG->dirroot . '/backup/util/settings/base_setting.class.php');73require_once($CFG->dirroot . '/backup/util/settings/backup_setting.class.php');74require_once($CFG->dirroot . '/backup/util/settings/root/root_backup_setting.class.php');75require_once($CFG->dirroot . '/backup/util/settings/activity/activity_backup_setting.class.php');76require_once($CFG->dirroot . '/backup/util/settings/section/section_backup_setting.class.php');77require_once($CFG->dirroot . '/backup/util/settings/course/course_backup_setting.class.php');78require_once($CFG->dirroot . '/backup/util/plan/base_plan.class.php');79require_once($CFG->dirroot . '/backup/util/plan/backup_plan.class.php');80require_once($CFG->dirroot . '/backup/util/plan/base_task.class.php');81require_once($CFG->dirroot . '/backup/util/plan/backup_task.class.php');82require_once($CFG->dirroot . '/backup/util/plan/base_step.class.php');83require_once($CFG->dirroot . '/backup/util/plan/backup_step.class.php');84require_once($CFG->dirroot . '/backup/util/plan/backup_structure_step.class.php');85require_once($CFG->dirroot . '/backup/util/plan/backup_execution_step.class.php');86require_once($CFG->dirroot . '/backup/controller/base_controller.class.php');87require_once($CFG->dirroot . '/backup/controller/backup_controller.class.php');88require_once($CFG->dirroot . '/backup/util/ui/base_moodleform.class.php');89require_once($CFG->dirroot . '/backup/util/ui/base_ui.class.php');90require_once($CFG->dirroot . '/backup/util/ui/base_ui_stage.class.php');91require_once($CFG->dirroot . '/backup/util/ui/backup_moodleform.class.php');92require_once($CFG->dirroot . '/backup/util/ui/backup_ui.class.php');93require_once($CFG->dirroot . '/backup/util/ui/backup_ui_stage.class.php');94require_once($CFG->dirroot . '/backup/util/ui/backup_ui_setting.class.php');95// And some moodle stuff too96require_once($CFG->dirroot.'/course/lib.php');97require_once($CFG->libdir.'/gradelib.php');...

Full Screen

Full Screen

class-backup.php

Source:class-backup.php Github

copy

Full Screen

...3class Backup {4 private $excludes;5 public $warnings = array();6 public $errors = array();7 private $backup_filename;8 private $database_dump_filename;9 private $backup_filepath = '';10 private $database_dump_filepath = '';11 private $status = null;12 private $type = 'complete';13 public function __construct( $backup_filename, $database_dump_filename = null ) {14 $this->backup_filename = $backup_filename;15 $this->database_dump_filename = $database_dump_filename;16 }17 public function set_type( $type ) {18 $this->type = $type;19 }20 public function set_backup_filename( $filename ) {21 $this->backup_filename = $filename;22 }23 public function set_status( Backup_Status $status ) {24 $this->status = $status;25 }26 public function set_excludes( Excludes $excludes ) {27 $this->excludes = $excludes;28 }29 public function run() {30 Path::get_instance()->cleanup();31 if ( 'file' !== $this->type ) {32 $this->backup_database();33 }34 if ( 'database' !== $this->type ) {35 $this->backup_files();36 }37 Path::get_instance()->cleanup();38 }39 public function backup_database() {40 if ( $this->status ) {41 $this->status->set_status( __( 'Backing up database...', 'backupwordpress' ) );42 }43 $database_backup_engines = apply_filters( 'hmbkp_database_backup_engines', array(44 new Mysqldump_Database_Backup_Engine,45 new IMysqldump_Database_Backup_Engine,46 ) );47 // Set the file backup engine settings48 if ( $this->database_dump_filename ) {49 foreach ( $database_backup_engines as &$backup_engine ) {50 $backup_engine->set_backup_filename( $this->database_dump_filename );51 }52 }53 // Dump the database54 $database_dump = $this->perform_backup( $database_backup_engines );55 if ( is_a( $database_dump, __NAMESPACE__ . '\\Backup_Engine' ) ) {56 $this->database_dump_filepath = $database_dump->get_backup_filepath();57 }58 // Fire up the file backup engines59 $file_backup_engines = apply_filters( 'hmbkp_file_backup_engines', array(60 new Zip_File_Backup_Engine,61 new Zip_Archive_File_Backup_Engine,62 ) );63 // Set the file backup engine settings64 foreach ( $file_backup_engines as &$backup_engine ) {65 $backup_engine->set_backup_filename( $this->backup_filename );66 $backup_engine->set_excludes( new Excludes( array( '*.zip', 'index.html', '.htaccess', '.*-running', '.files' ) ) );67 }68 // Zip up the database dump69 $root = Path::get_root();70 Path::get_instance()->set_root( Path::get_path() );71 $file_backup = $this->perform_backup( $file_backup_engines );72 Path::get_instance()->set_root( $root );73 if ( is_a( $file_backup, __NAMESPACE__ . '\\Backup_Engine' ) ) {74 $this->backup_filepath = $file_backup->get_backup_filepath();75 }76 // Delete the Database Backup now that we've zipped it up77 if ( file_exists( $this->database_dump_filepath ) ) {78 unlink( $this->database_dump_filepath );79 }80 }81 public function backup_files() {82 if ( $this->status ) {83 $this->status->set_status( __( 'Backing up files...', 'backupwordpress' ) );84 }85 // Fire up the file backup engines86 $backup_engines = apply_filters( 'hmbkp_file_backup_engines', array(87 new Zip_File_Backup_Engine,88 new Zip_Archive_File_Backup_Engine,89 ) );90 // Set the file backup engine settings91 foreach ( $backup_engines as &$backup_engine ) {92 $backup_engine->set_backup_filename( $this->backup_filename );93 if ( $this->excludes ) {94 $backup_engine->set_excludes( $this->excludes );95 }96 }97 $file_backup = $this->perform_backup( $backup_engines );98 if ( is_a( $file_backup, __NAMESPACE__ . '\\Backup_Engine' ) ) {99 $this->backup_filepath = $file_backup->get_backup_filepath();100 }101 }102 /**103 * Perform the backup by iterating through each Backup_Engine in turn until104 * we find one which works. If a backup filename or any excludes have been105 * set then those are passed to each Backup_Engine.106 *107 * @return Backup_Engine|false The successful backup engine or false on failure.108 */109 public function perform_backup( array $backup_engines ) {110 foreach ( $backup_engines as $backup_engine ) {111 /**112 * If the backup_engine completes the backup then we113 * clear any errors or warnings from previously failed backup_engines114 * and return the successful one.115 */116 if ( $backup_engine->backup() ) {117 $this->errors = array();118 $this->warnings = $backup_engine->get_warnings();119 return $backup_engine;120 }121 // Store all the errors and warnings as they are shown if all engines fail122 $this->warnings = array_merge( $this->warnings, $backup_engine->get_warnings() );123 $this->errors = array_merge( $this->errors, $backup_engine->get_errors() );124 }125 return false;126 }127 public function get_warnings() {128 return $this->warnings;129 }130 public function get_errors() {131 return $this->errors;132 }133 /**134 * Add an warning to the errors warnings.135 *136 * A warning is always treat as non-fatal and should only be used for recoverable137 * issues with the backup process.138 *139 * @param string $context The context for the warning.140 * @param string $warning The warning that was encountered.141 */142 public function warning( $context, $warning ) {143 if ( empty( $context ) || empty( $warning ) ) {144 return;145 }146 // Ensure we don't store duplicate warnings by md5'ing the error as the key147 $this->warnings[ $context ][ md5( implode( ':', (array) $warning ) ) ] = $warning;148 }149 /**150 * Back compat with old error method151 *152 * Only the backup engines themselves can fire fatal errors153 *154 * @deprecated 3.4 Backup->warning( $context, $warning )155 */156 public function error( $context, $message ) {157 _deprecated_function( __FUNCTION__, '3.4', 'Backup->warning( $context, $warning )' );158 $this->warning( $context, $message );159 }160 public function get_database_backup_filepath() {161 return $this->database_dump_filepath;162 }163 public function get_backup_filepath() {164 return $this->backup_filepath;165 }166 /**167 * Back compat with old method name168 *169 * @see Backup::get_backup_filepath()170 * @deprecated 3.4 Use Backup::get_backup_filepath()171 */172 public function get_archive_filepath() {173 _deprecated_function( __FUNCTION__, '3.4', 'get_backup_filepath()' );174 return $this->get_backup_filepath();175 }176}...

Full Screen

Full Screen

backup

Using AI Code Generation

copy

Full Screen

1include 'backup_class.php';2$backup = new backup_class;3$backup->setBackupPath('/var/www/html/backup/');4$backup->setBackupFile('backup.zip');5$backup->setBackupPath('/var/www/html/backup/');6$backup->setBackupFile('backup.zip');7$backup->setBackupPath('/var/www/html/backup/');8$backup->setBackupFile('backup.zip');9$backup->setBackupPath('/var/www/html/backup/');10$backup->setBackupFile('backup.zip');11$backup->setBackupPath('/var/www/html/backup/');12$backup->setBackupFile('backup.zip');13$backup->setBackupPath('/var/www/html/backup/');14$backup->setBackupFile('backup.zip');15$backup->setBackupPath('/var/www/html/backup/');16$backup->setBackupFile('backup.zip');17$backup->setBackupPath('/var/www/html/backup/');18$backup->setBackupFile('backup.zip');19$backup->setBackupPath('/var/www/html/backup/');20$backup->setBackupFile('backup.zip');21$backup->setBackupPath('/var/www/html/backup/');

Full Screen

Full Screen

backup

Using AI Code Generation

copy

Full Screen

1$backup = new pts_backup();2$backup->backup_test_profile('test-profile.xml');3$backup = new pts_backup();4$backup->restore_test_profile('test-profile-backup.xml');5$backup = new pts_backup();6$backup->restore_test_profile('test-profile-backup.xml');7$backup = new pts_backup();8$backup->restore_test_profile('test-profile-backup.xml');9$backup = new pts_backup();10$backup->restore_test_profile('test-profile-backup.xml');11$backup = new pts_backup();12$backup->restore_test_profile('test-profile-backup.xml');

Full Screen

Full Screen

backup

Using AI Code Generation

copy

Full Screen

1$backup= new phodevi_backup();2$backup->backup();3$backup->restore();4include('2.php');5$backup= new phodevi_backup();6$backup->backup();7$backup->restore();8include('2.php');9$backup= new phodevi_backup();10$backup->backup();11$backup->restore();12include('2.php');13$backup= new phodevi_backup();14$backup->backup();15$backup->restore();16include('2.php');17$backup= new phodevi_backup();18$backup->backup();19$backup->restore();20include('2.php');21$backup= new phodevi_backup();22$backup->backup();23$backup->restore();

Full Screen

Full Screen

Automation Testing Tutorials

Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Run Phoronix-test-suite automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Run Selenium Automation Tests on LambdaTest Cloud Grid

Trigger Selenium automation tests on a cloud-based Grid of 3000+ real browsers and operating systems.

Test now for Free

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful