Server Migration and Course Restore and Images

Server Migration and Course Restore and Images

by Alan Cherwinski -
Number of replies: 6

Hello,

I am moving a Moodle site to a new server. It is a new domain and cpanel account.  I can't be certain that the server configuration are exactly the same, so I decided to opt for a fresh install of the latest Moodle version and to restore the courses individually. 

When I restore the course onto the new server the images are behaving oddly.  

The new server is using https and the restored courses' image links remain http.   I assumed the restore would take care of the urls.  The course datafile numbers are off. The image are pointing to the wrong directory.

If I manually edit the images to the correct course Moodle file the urls are including draftfile.php. 

Some of the image urls in the restored course are still pointing to the old domain name.

Is there a good guide available on restoring a course to a new server.  The images are an obvious problem, but it it likely that all moodledata file are also unconnected?


Thanks

Average of ratings: -
In reply to Alan Cherwinski

Re: Server Migration and Course Restore and Images

by Visvanath Ratnaweera -
Picture of Particularly helpful Moodlers Picture of Translators
There is a https://docs.moodle.org/en/Search_and_replace_tool. Can't promise that it will solve all those broken links, it could make things worse (read the warnings it displays).

The burning question is, why this ad-hoc migration when there is an official, well tested procedure https://docs.moodle.org/en/Moodle_migration ?
In reply to Visvanath Ratnaweera

Re: Server Migration and Course Restore and Images

by Alan Cherwinski -
Thank you Visvanath, I had not seen the migration tools previously. My Moodle server and courses have been running with regular update for well over a decade, I thought it might make sense to start with a clean install. I had thought any legacy issues would be corrected by the restore process rather than copies over with the database import and data copy. I will give official method a try and see if I get more reliable results. Thank you.
In reply to Visvanath Ratnaweera

Re: Server Migration and Course Restore and Images

by Alan Cherwinski -
Hello Visvanath,

For one of the Moodle installations I used the migration process you brought to my attention and it work perfectly - Thank you.

I discovered another legacy installation that has pre-migration issues that have probably come from earlier upgrades.

The site and courses are very old!

The images are all appearing as broken links. The files are all there in the moodle data directory.

If I look at the existing image url I see: http://<>/file.php/52/Dog_reading.jpg that is a broken image.

If I edit the image in the html editor and reconnect the image to the legacy image file I get: https://<>/draftfile.php/1984/user/draft/660080249/Dog_reading.jpg that when saved becomes: https://<>/pluginfile.php/2433/course/section/442/Dog_reading.jpg

Obviously I did something wrong in the past while doing an upgrade, but what exactly would change the file structure from file.php/52/Dog_reading.jpg to pluginfile.php/2433/course/section/442/Dog_reading.jpg ?

All the courses on the installation have this problem.

Thank for the advice. I doubt there is any fix beyond editing each image manually.
In reply to Alan Cherwinski

Re: Server Migration and Course Restore and Images

by Visvanath Ratnaweera -
Picture of Particularly helpful Moodlers Picture of Translators
Hi

Yes, if the conditions are right, the search and replace does wonders. Beware, if not!

The new site, "very old" you say. Let me guess, it is Moodle 1 series! ;)

You are running in to the legacy files crash site. It was such a long time ago, can't remember the details. The point is that Moodle gave up legacy files somewhere along the line. May be there are others who remember. Legacy files were another reason behind the general advice to recreate Moodle 1 courses from scratch.
In reply to Visvanath Ratnaweera

Re: Server Migration and Course Restore and Images

by Ken Task -
Picture of Particularly helpful Moodlers

Don't remember ... but ... maybe this will help?

https://docs.moodle.org/39/en/Legacy_course_files

Seem to re-call a plugin ... called 'poof' ... that did convert legacy to new file system, but it did require to visit each to click the 'poof' button in the editor.

I once tinkered with finding a way to rid course of legacy by 'doctoring' a backup, uncompressed, changing 'legacy' to 'draft' in files.xml, then compressing the backup so that moodle would recognize it as a backup then restoring.

It worked ... could turn off legacy files and images showed etc.  but ... for some reason, those files were now stuck in 'draft'! :\

If one wants no future troubles with the courses, probably worth the time spent in fixing .... even if you have to visit each one to make the change.   Yes, painful but ...

'SoS', Ken


In reply to Ken Task

Re: Server Migration and Course Restore and Images

by Alan Cherwinski -
Thank you Ken and Visvanath,

Yes the course were probably developed in the late 1.X era. I had hoped that keeping the site up-to-date and restoring the course would reset the file system. I as well encountered the stuff stuck in draft or not deleted (cleaned-up) when deleted. I will carefully examine the value of the all the manual work and look into "poof".
with gratitude, Alan