Search moodle.org's
Developer Documentation

See Release Notes

  • Bug fixes for general core bugs in 3.10.x will end 8 November 2021 (12 months).
  • Bug fixes for security issues in 3.10.x will end 9 May 2022 (18 months).
  • PHP version: minimum PHP 7.2.0 Note: minimum PHP version has increased since Moodle 3.8. PHP 7.3.x and 7.4.x are supported too.

Differences Between: [Versions 310 and 311] [Versions 310 and 400] [Versions 310 and 401] [Versions 310 and 402] [Versions 310 and 403]

(no description)

Copyright: 2010 onwards Eloy Lafuente (stronk7) {@link http://stronk7.com}
License: http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
File Size: 391 lines (16 kb)
Included or required:0 times
Referenced: 3 times
Includes or requires: 0 files

Defines 2 classes

backup_helper:: (9 methods):
  check_and_create_backup_dir()
  clear_backup_dir()
  delete_backup_dir()
  delete_dir_contents()
  delete_old_backup_dirs()
  log()
  store_backup_file()
  is_sqlparam()
  get_inforef_itemnames()

backup_helper_exception:: (1 method):
  __construct()


Class: backup_helper  - X-Ref

Base abstract class for all the helper classes providing various operations

TODO: Finish phpdocs
check_and_create_backup_dir($backupid)   X-Ref
Given one backupid, create all the needed dirs to have one backup temp dir available


clear_backup_dir($backupid, \core\progress\base $progress = null)   X-Ref
Given one backupid, ensure its temp dir is completely empty

If supplied, progress object should be ready to receive indeterminate
progress reports.

param: string $backupid Backup id
param: \core\progress\base $progress Optional progress reporting object

delete_backup_dir($backupid, \core\progress\base $progress = null)   X-Ref
Given one backupid, delete completely its temp dir

If supplied, progress object should be ready to receive indeterminate
progress reports.

param: string $backupid Backup id
param: \core\progress\base $progress Optional progress reporting object

delete_dir_contents($dir, $excludeddir='', \core\progress\base $progress = null)   X-Ref
Given one fullpath to directory, delete its contents recursively
Copied originally from somewhere in the net.
TODO: Modernise this

If supplied, progress object should be ready to receive indeterminate
progress reports.

param: string $dir Directory to delete
param: string $excludedir Exclude this directory
param: \core\progress\base $progress Optional progress reporting object

delete_old_backup_dirs($deletefrom, \core\progress\base $progress = null)   X-Ref
Delete all the temp dirs older than the time specified.

If supplied, progress object should be ready to receive indeterminate
progress reports.

param: int $deletefrom Time to delete from
param: \core\progress\base $progress Optional progress reporting object

log($message, $level, $a, $depth, $display, $logger)   X-Ref
This function will be invoked by any log() method in backup/restore, acting
as a simple forwarder to the standard loggers but also, if the $display
parameter is true, supporting translation via get_string() and sending to
standard output.


store_backup_file($backupid, $filepath, \core\progress\base $progress = null)   X-Ref
Given one backupid and the (FS) final generated file, perform its final storage
into Moodle file storage. For stored files it returns the complete file_info object

Note: the $filepath is deleted if the backup file is created successfully

If you specify the progress monitor, this will start a new progress section
to track progress in processing (in case this task takes a long time).

param: int $backupid
param: string $filepath zip file containing the backup
param: \core\progress\base $progress Optional progress monitor
return: stored_file if created, null otherwise

is_sqlparam($value)   X-Ref
This function simply marks one param to be considered as straight sql
param, so it won't be searched in the structure tree nor converted at
all. Useful for better integration of definition of sources in structure
and DB stuff


get_inforef_itemnames()   X-Ref
This function returns one array of itemnames that are being handled by
inforef.xml files. Used both by backup and restore


Class: backup_helper_exception  - X-Ref

__construct($errorcode, $a=NULL, $debuginfo=null)   X-Ref
No description