Beispiel #1
0
 public static function run()
 {
     // On a besoin du path où mettre le fichier de backup
     $opts = array('path' => 'y', 'sn' => 'y');
     $r = command::get_runner($opts);
     $options = getopt($r->shortoptions, $r->options);
     $error = false;
     if (!isset($options['path']) || !is_dir($options['path'])) {
         logger::shout('loption --path nest pas valide');
         $error = true;
     }
     if (!isset($options['sn'])) {
         logger::shout('indiquer le shortname --sn ');
         $error = true;
     }
     if ($error) {
         return;
     }
     // $permissions = fileperms($options['path']);
     // logger::shout($options['path'] . ' permissions:' . $permissions. PHP_EOL);
     backup::execute($options['sn'], $options['path']);
 }
Beispiel #2
0
 public static function run()
 {
     // On a besoin du path où mettre le fichier de backup
     $opts = array('file' => 'y', 'cat' => 'y');
     $r = command::get_runner($opts);
     $options = getopt($r->shortoptions, $r->options);
     $error = false;
     if (!isset($options['file'])) {
         logger::shout('loption --file doit etre indiquee');
         return;
     }
     if (!file_exists($options['file'])) {
         cli_error("Backup file '" . $options['file'] . "' does not exist.");
         $error = true;
     }
     if (!is_readable($options['file'])) {
         cli_error("Backup file '" . $options['file'] . "' is not readable.");
         $error = true;
     }
     if (!isset($options['cat'])) {
         logger::shout('indiquer la categorie --cat ');
         $error = true;
     }
     global $DB;
     // Check if category is OK.
     if (isset($options['cat'])) {
         $category = $DB->get_record('course_categories', array('id' => $options['cat']), '*', MUST_EXIST);
         if (!isset($category->id)) {
             logger::shout('La categorie ' . $options['cat'] . ' nexiste pas.');
             $error = true;
         }
     }
     if ($error) {
         return;
     }
     // $permissions = fileperms($options['path']);
     // logger::shout($options['path'] . ' permissions:' . $permissions. PHP_EOL);
     restore::execute($options['file'], $options['cat']);
 }