Moving courses to new server

Moving courses to new server

by Harold Bieber -
Number of replies: 4

I have moodle 2.8 with a bunch of courses running on an old server. I have a new server that I will be installing Ubuntu 18.04 server on and Moodle 3.6 (unless someone has a reason not to go to 3.6 yet). How can I move the current courses to the new server. I use the older courses as templates when creating new courses. My old Moodle has files like this:

Fall2018
-Contracts 101
-Civ Pro 1


Archives/Summer 2018
-Contracts 101-summer
-Civ Pro 1-summer

I follow this course rollover procedure: 

So I archive a course, then use the archived course to create the new course. That is the reason I want to copy all the courses from old server to new. Old server is running Ubuntu 14.04

Thanks for any insight on this!!

Harold


Average of ratings: -
In reply to Harold Bieber

Re: Moving courses to new server

by Howard Miller -
Picture of Core developers Picture of Documentation writers Picture of Particularly helpful Moodlers Picture of Peer reviewers Picture of Plugin developers

How many courses are we talking about?

If it's hundreds (thousands?) you can just migrate the entire site - see Moodle_migration

Failing that use Course_backup on the old site and then Course_restore on the new site. One at a time. 

Sorry - too lazy to watch the video.

In reply to Howard Miller

Re: Moving courses to new server

by Harold Bieber -

Thanks Howard!! Both options look pretty straight forward. Do you think there will be in issue migrating the data from a moodle 2.8 to moodle 3.6 server?

In reply to Harold Bieber

Re: Moving courses to new server

by Ken Task -
Picture of Particularly helpful Moodlers

quickie ... so there might be some typos and corrections below.  Once xferred 4000 courses from old server to new server and had them restored to categories (the restore piece to this with moosh not shared here) in about 4 hours.

On old server.
Set backup preferences as desired (no user etc.)
Automated backups if they are working to a designated directory outside of
moodledata ... where ever you have plenty of space.

OR
to make it easier to rebuild on the new server:
use admin/cli/backup.php (still set backup preferences) to loop through a listing
of course ID's for a category of courses and have that backup.php script
save to a designated directory outside of Moodle only to a category directory.

Category: Academic
Course ID's 32.4.7.2.43.6
File containing CIDS ... acadcids10.txt .. one CID per line

script

/srv/www/moodle/admin/cli# cat niclbackupsacad

#!/bin/bash
#
# echo $1;
cd /srv/www/moodle/admin/cli/;
for i in `cat /srv/www/moodle/admin/cli/acadcids10.txt`
do
    echo "Course ID in que:" $i;
    php backup.php --courseid=$i --destination=/srv/backups/acad/
done
ls -l /srv/backups/acad/;
echo 'Done!';

So one ends up with something like this:

-rw-r--r-- 1 root root     267259 Dec 16  2017 backup-moodle2-course-117-varsity_softball-20171216-0749-nu.mbz
-rw-r--r-- 1 root root    3715363 Dec 16  2017 backup-moodle2-course-1303-service-learning_center-20171216-0759-nu.mbz
-rw-r--r-- 1 root root     108147 Dec 16  2017 backup-moodle2-course-1309-social_work_junior_field_placement-20171216-0759-nu.mbz
-rw-r--r-- 1 root root    2675418 Dec 16  2017 backup-moodle2-course-1552-commdptadv-20171216-0717-nu.mbz
-rw-r--r-- 1 root root      47626 Dec 16  2017 backup-moodle2-course-2230-hpsd-20171216-0727-nu.mbz

now create a file that provides a listing of just. the backup file:

acadfiles.txt

Looks like:

backup-moodle2-course-3815-comm413.01.f17-20171216-0718-nu.mbz
backup-moodle2-course-3816-comm218250.01.f17-20171216-0718-nu.mbz
backup-moodle2-course-3817-comm292.01.f17-20171216-0718-nu.mbz
backup-moodle2-course-3819-psyc326.01.f17-20171216-0756-nu.mbz
backup-moodle2-course-3821-chem477.01.f17-20171216-0753-nu.mbz
backup-moodle2-course-3822-chemphys490.01.f17-20171216-0753-nu.mbz
backup-moodle2-course-3823-chem108.01.f17-20171216-0753-nu.mbz
backup-moodle2-course-3825-chem101.02.f17-20171216-0754-nu.mbz
backup-moodle2-course-3827-mathcpsc490.01.f17-20171216-0731-nu.mbz

make a symlink from web root of old server to the location of these backups ... you'll remove the symlink later

ln -fs /srv/backups/acad acadbackups

URL then would be: https://oldserver/acadbackups/

Go to new server ...
create a file system repo in moodledata/reposository called 'acad'
cd acad
wget http://oldserver/acadbackups/acadfiles.txt

That acquires the file listing.
Edit the file listing (acadfiles.txt) and add the URL to teh front of each file in the listing.

Line one above would now look like:
http://oldserver/acadbackups/backup-moodle2-course-3815-comm413.01.f17-20171216-0718-nu.mbz

Do that for every course backup listed in that file.

Once that's done, use wget to get them all:

wget -i acadfiles.txt

Each backup file will be transferred to the where you are located ...

moodledata/repostiory/acad/

Change ownerships permissions to allow Moodle to see 'acad' and all the backup files therein.

Go to the new Moodle and to a course that has file system repo turned on and pointed to 'acad'.
Restore.

Or check out moosh and the command to restore a course to a category by category ID.

'spirit of sharing, Ken