1. Create a test course "Test course" from Site administration > Development > Make test course.
2. Create a course "Course for restore" and note id of the course.
3. Open any activity in the "Test course" and note id of the course module.
4. Open console and run the backup command with cmid: (X is cmid from 3.)
php admin/cli/backup.php --cmid=X --destination=/tmp/
|
5. Confirm, the output looks like below and the backup is for 'activity'.
== Performing backup... ==
|
Writing /tmp/backup-moodle2-activity-15-page15-20231010-1349.mbz
|
Backup completed.
|
6. Open console and run the backup command with cmid and courseid: (X is cmid from 3.)
php admin/cli/backup.php --cmid=X --courseid=1 --destination=/tmp/
|
7. Confirm, the output looks like below and the backup is for 'course'. (ignore cmid option if courseid is set)
== Performing backup... ==
|
Writing /tmp/backup-moodle2-course-1-moodle-master-20231102-1913.mbz
|
Backup completed.
|
8. Run restore command with courseid option: (Y is courseid from 2 and file is path from result of 5.)
php admin/cli/restore_backup.php --courseid=Y --file=/tmp/backup-moodle2-activity-15-page15-20231010-1349.mbz
|
9. Confirm the output looks like below and the restore to the 'course'.
== Extracting backup file to: /var/lib/sitedata/temp/backup/restore_6524bd652ccfc ==
|
== Preprocessing backup file ==
|
== Restored course ID: 4 ==
|
10. Go to the course page and confirm the activity is restored to the course.
11. Run restore command with categoryid option.
php admin/cli/restore_backup.php --categoryid=1 --file=/tmp/backup-moodle2-activity-27-page27-20231031-1640.mbz
|
12. Confirm the output looks like below and the activity is restored to a new course.
== Extracting backup file to: /var/lib/sitedata/temp/backup/restore_6543554f2600a ==
|
== Preprocessing backup file ==
|
== Restored course ID: 13 ==
|
13. Go to the category page and confirm the activity is restored to a new course.
14. Run restore command with categoryid and courseid option.
php admin/cli/restore_backup.php --courseid=Y --categoryid=1 --file=/tmp/backup-moodle2-activity-27-page27-20231031-1640.mbz
|
15. Confirm the output looks like below and the activity is restored to a new course.
== Extracting backup file to: /var/lib/sitedata/temp/backup/restore_6543554f2600a ==
|
== Preprocessing backup file ==
|
== Restored course ID: 13 ==
|
16. Go to the category page and confirm the activity is restored to a new course. (ignore courseid option if categoryid is set)
17. Run restore command with invalid categoryid option.
php admin/cli/restore_backup.php --categoryid=99999 --file=/tmp/backup-moodle2-activity-27-page27-20231031-1640.mbz
|
18. Confirm the output looks like below:
!!! Incorrect category ID! !!!
|
!!
|
Error code: invalidcategoryid !!
|
!! Stack trace: * line 85 of /admin/cli/restore_backup.php: moodle_exception thrown
|
!!
|
19. Run restore command with invalid courseid option.
php admin/cli/restore_backup.php --courseid=99999 --file=/tmp/backup-moodle2-activity-27-page27-20231031-1640.mbz
|
20. Confirm the output looks like below:
!!! You are trying to use an invalid course ID !!!
|
!!
|
Error code: invalidcourseid !!
|
!! Stack trace: * line 89 of /admin/cli/restore_backup.php: moodle_exception thrown
|
!!
|