See Release Notes
Long Term Support Release
Differences Between: [Versions 401 and 402] [Versions 401 and 403]
1 <?php 2 3 // This file is part of Moodle - http://moodle.org/ 4 // 5 // Moodle is free software: you can redistribute it and/or modify 6 // it under the terms of the GNU General Public License as published by 7 // the Free Software Foundation, either version 3 of the License, or 8 // (at your option) any later version. 9 // 10 // Moodle is distributed in the hope that it will be useful, 11 // but WITHOUT ANY WARRANTY; without even the implied warranty of 12 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 // GNU General Public License for more details. 14 // 15 // You should have received a copy of the GNU General Public License 16 // along with Moodle. If not, see <http://www.gnu.org/licenses/>. 17 18 /** 19 * Automated backups CLI cron 20 * 21 * This script executes 22 * 23 * @package core 24 * @subpackage cli 25 * @copyright 2010 Sam Hemelryk 26 * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later 27 */ 28 29 define('CLI_SCRIPT', true); 30 31 require(__DIR__.'/../../config.php'); 32 require_once($CFG->libdir.'/clilib.php'); // cli only functions 33 require_once($CFG->libdir.'/cronlib.php'); 34 35 // now get cli options 36 list($options, $unrecognized) = cli_get_params(array('help'=>false), 37 array('h'=>'help')); 38 39 if ($unrecognized) { 40 $unrecognized = implode("\n ", $unrecognized); 41 cli_error(get_string('cliunknowoption', 'admin', $unrecognized)); 42 } 43 44 if ($options['help']) { 45 $help = 46 "Execute automated backups. 47 48 This script executes automated backups completely and is designed to be 49 called via cron. 50 51 Options: 52 -h, --help Print out this help 53 54 Example: 55 \$sudo -u www-data /usr/bin/php admin/cli/automated_backups.php 56 "; 57 58 echo $help; 59 die; 60 } 61 if (CLI_MAINTENANCE) { 62 echo "CLI maintenance mode active, backup execution suspended.\n"; 63 exit(1); 64 } 65 66 if (moodle_needs_upgrading()) { 67 echo "Moodle upgrade pending, backup execution suspended.\n"; 68 exit(1); 69 } 70 71 require_once($CFG->libdir.'/adminlib.php'); 72 require_once($CFG->libdir.'/gradelib.php'); 73 74 if (!empty($CFG->showcronsql)) { 75 $DB->set_debug(true); 76 } 77 if (!empty($CFG->showcrondebugging)) { 78 set_debugging(DEBUG_DEVELOPER, true); 79 } 80 81 $starttime = microtime(); 82 83 /// emulate normal session 84 cron_setup_user(); 85 86 /// Start output log 87 $timenow = time(); 88 89 mtrace("Server Time: ".date('r',$timenow)."\n\n"); 90 91 // Run automated backups if required. 92 require_once($CFG->dirroot.'/backup/util/includes/backup_includes.php'); 93 require_once($CFG->dirroot.'/backup/util/helper/backup_cron_helper.class.php'); 94 backup_cron_automated_helper::run_automated_backup(backup_cron_automated_helper::RUN_IMMEDIATELY); 95 96 mtrace("Automated cron backups completed correctly"); 97 98 $difftime = microtime_diff($starttime, microtime()); 99 mtrace("Execution took ".$difftime." seconds");
title
Description
Body
title
Description
Body
title
Description
Body
title
Body