1. Create a user.
2. Create a course "My Course".
3. Enroll the user with student role.
4. Enroll admin user with teacher role.
5. Add an assignment activity.
6. Add a submission, upload a file, submit the submission.
7. Grade the submission.
8. Take a backup of the course.
9. Save the backup file to be able to use it from CLI further.
10. Site administration > Development > Debugging page.
11. Set debugging to NONE.
12. Open console and run the command:
php admin/cli/restore_backup.php
|
13. Confirm, the output looks like:
Restore backup into provided category.Options:
|
-f, --file=STRING Path to the backup file.
|
-c, --categoryid=INT ID of the category to restore too.
|
-s, --showdebugging Show developer level debugging information
|
-h, --help Print out this help.Example:
|
$sudo -u www-data /usr/bin/php admin/cli/restore_backup.php --file=/path/to/backup/file.mbz --categoryid=1
|
14. Run the command with path to a file that doesn't exist:
php admin/cli/restore_backup.php --file=/fake/file.mbz --categoryid=1
|
15. Confirm, the output looks like:
!!! Sorry, the requested file could not be found !!!
|
16. Run the command with path to a file that doesn't exist and with `–showdebugging` option:
php admin/cli/restore_backup.php --file=/fake/file.mbz --categoryid=1 --showdebugging
|
17. Confirm, the output looks like:
Default exception handler: Sorry, the requested file could not be found Debug:
|
Error code: filenotfound
|
* line 498 of /lib/setuplib.php: moodle_exception thrown
|
* line 76 of /admin/cli/restore_backup.php: call to print_error()!!! Sorry, the requested file could not be found !!!
|
!!
|
Error code: filenotfound !!
|
!! Stack trace: * line 498 of /lib/setuplib.php: moodle_exception thrown
|
* line 76 of /admin/cli/restore_backup.php: call to print_error()
|
!!
|
18. Run the command with path to the backup file and category id set to 1:
php admin/cli/restore_backup.php --file=/siteroot/backup-moodle2-course-2-test_course-20200717-1744.mbz --categoryid=1
|
19. Confirm, the output looks like:
== Extracting backup file to: /var/lib/sitedata/temp/backup/restore_5f190090dd00a ==
|
== Preprocessing backup file ==
|
== Restored course id: 43 ==
|
20. Navigate to Site administration > Courses > Manage courses and categories and create a new category.
21. Run the command with short keys, extra debugging and just created category id:
php admin/cli/restore_backup.php -f=/siteroot/backup-moodle2-course-2-test_course-20200717-1744.mbz -c=2 -s
|
22. Confirm, the output looks like:
== Extracting backup file to: /var/lib/sitedata/temp/backup/restore_5f1900b9ddd9a ==
|
== Preprocessing backup file ==
|
instantiating restore controller fba4a8322b6dfefd8971bc1653df7e69
|
setting controller status to 100
|
loading backup info
|
loading controller plan
|
setting controller status to 300
|
applying restore defaults
|
Unknown setting: questionbank
|
setting controller status to 400
|
checking plan security
|
setting controller status to 600
|
saving controller to db
|
calculating controller checksum ddd10245fd8923e89a2812e852876d2b
|
loading controller from db
|
setting controller status to 700
|
saving controller to db
|
calculating controller checksum fa2d006d9a33a6f8de1f2145aaf4a501
|
loading controller from db
|
setting controller status to 800
|
saving controller to db
|
calculating controller checksum 78ba61bef5a88d051625612e9cd6379d
|
loading controller from db
|
processing file aliases queue
|
setting controller status to 1000
|
saving controller to db
|
== Restored course id: 44 ==
|
23. Run the command with category id that doesn't exist:
php admin/cli/restore_backup.php --file=/siteroot/backup-moodle2-course-2-my_course-20200723-1057.mbz --categoryid=666
|
24. Confirm, the script fails and output looks like:
!!! Incorrect category ID! !!!
|
25. Run the same command with showdebugging option:
php admin/cli/restore_backup.php --file=/siteroot/backup-moodle2-course-2-my_course-20200723-1057.mbz --categoryid=666 --showdebugging
|
26. Confirm, the output looks like:
Default exception handler: Incorrect category ID! Debug:
|
Error code: invalidcategoryid
|
* line 498 of /lib/setuplib.php: moodle_exception thrown
|
* line 80 of /admin/cli/restore_backup.php: call to print_error()!!! Incorrect category ID! !!!
|
!!
|
Error code: invalidcategoryid !!
|
!! Stack trace: * line 498 of /lib/setuplib.php: moodle_exception thrown
|
* line 80 of /admin/cli/restore_backup.php: call to print_error()
|
!!
|
27. Navigate to `Site home`.
28. Confirm, both restored courses are available.
29. Confirm, both restored courses are nicely named ("My Course copy 1" and "My Course copy 2" accordingly).
30. Walk through the restored course and:
31. Confirm, the user is enrolled with student role.
32. Confirm, the admin user is enrolled with teacher role.
33. Confirm, the assignment activity is available.
34. Confirm, the assignment activity has submitted submission with a file attached.
35. Confirm, the submitted submission has its grade.
36. Navigate to Site administration > Courses > Manage courses and categories
37. Confirm, the second restored course is aligned to new category.