Moodle oddly omits the ability to perform backup and restore via the CLI. Consider that fixed.
- Install this directory at
/admin/tool/backupcli
. - Execute the usual Moodle upgrade process.
- ???
- Profit.
Backup a course:
$ php admin/tool/backupcli/cli/backup.php --type=course --id=123 --file=$HOME/backup-123.mbz
Or section:
$ php admin/tool/backupcli/cli/backup.php --type=section --id=123 --file=$HOME/backup-123.mbz
Or activity:
$ php admin/tool/backupcli/cli/backup.php --type=activity --id=123 --file=$HOME/backup-123.mbz
Restore a backup to a new course in th specified category:
$ php admin/tool/backupcli/cli/restore.php --file=$HOME/backup-123.mbz --categoryid=1
Or overwrite the specified course, deleting existing content:
$ php admin/tool/backupcli/cli/restore.php --file=$HOME/backup-123.mbz --courseid=123
If you're backing up a course and restoring to the same site, be sure to use
the --samesite
option for a hefty improvement in performance.