Search moodle.org's
Developer Documentation

See Release Notes
Long Term Support Release

  • Bug fixes for general core bugs in 4.1.x will end 13 November 2023 (12 months).
  • Bug fixes for security issues in 4.1.x will end 10 November 2025 (36 months).
  • PHP version: minimum PHP 7.4.0 Note: minimum PHP version has increased since Moodle 4.0. PHP 8.0.x is supported too.

Differences Between: [Versions 310 and 401] [Versions 311 and 401] [Versions 39 and 401] [Versions 400 and 401]

(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: 393 lines (16 kb)
Included or required:0 times
Referenced: 1 time
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($deletebefore, \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 $deletebefore Delete files and directories older than this time
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