Quantcast
Channel: Backup and restore
Viewing all articles
Browse latest Browse all 6815

How to restore courses from a lower version Moodle

$
0
0
von Ken Task.  

Responses to your numbered items:

1 - not so strange really.

2 - can we backup a full category of courses

No, but you can use the backup.php script to loop through course ID's of the courses in a category and save to a mount point that is on the new server and which is really a moodledata/repository/ filesystem called restores.  restores goes deeper ... a directory for oh, say 'ss' courses ... (Social Studies).

Then, on new server, could use the GUI to restore all those to a category that matches the old server.

2 catch 22's to using restoring course backups to a new higher version of Moodle

1- plugins.   New server must have all the same plugins that existed on old server - especially any quiz addons.

2-if you restore via GUI, and IF the  4.1.highest restore process is now totally a background process ... you have to wait on that screen until it finishes.   Things like web server time outs, memory for a script to consume etc. come into play.

But, you could, for 2- above use command line to restore the courses to a category in a looping bash shell script ... one at a time ... and you might have to put that command in a 'no hang up' (nohup) wrapper or your ssh session might time out!

Example of script for backups you would have to adjust:

niclbackups

cd /var/www/html/admin/cli/;
for i in `cat /var/www/html/admin/cli/cids.txt`
do
    echo "Course ID in que:" $i;
    php backup.php --courseid=$i --destination=/mntpoint/onnewserver/
done
ls -l /mntpoint/onnewserver;
echo 'Done!';

On new server and run from code/admin/cli ... here's the help on the restore_backup.php script.

php restore_backup.php
Restore backup into provided category or course.
If courseid is set, course module/s will be added into the course.

Options:
-f, --file=STRING       Path to the backup file.
-c, --categoryid=INT    ID of the course category to restore to. This option is ignored when restoring an activity and courseid is set.
-C, --courseid=INT      ID of the course to restore to. This option is ignored when restoring a course and the categoryid is set.
-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/coursebackup.mbz --categoryid=1

$sudo -u www-data /usr/bin/php admin/cli/restore_backup.php --file=/path/to/backup/activitybackup.mbz --courseid=1

Due to the size of courses you've mentoned ... one could create a listing of course.mbz files - those are usually long but include the course short name and course ID as it existed on old system, and loop through those restoring to a category you have created for them in advance.  Don't have ane example script like that but it is similar to the one above for backups.

Again, large course restores might have to be put into a nohup wrapper.  Example:

nohup php ./restore_backup.php --file=/path/to/backup/coursebackup.mbz --categoryid=1 &

That will launch the command and exit starting a nohup.out log at that same location which you can watch the progress using:

tail -f ./nohup.out

'SoS', Ken


Viewing all articles
Browse latest Browse all 6815

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>