Moodle Migration

Moodle Migration

by Mario Gharib -
Number of replies: 4

Dear Moodlers,

We need your help asap, because we are about to upgrade Moodle from 2.9 to 3.1,
We are trying to test the upgrade on a different Linux server,

I read that we need to replace the old hostname by the new hostname,

php admin/tool/replace/cli/replace.php --search=//oldsitehost --replace=//newsitehost

the problem is that whenever we try to type the command above,

php admin/tool/replace/cli/replace.php --search=//moodle2.2 --replace=//clone-moodle

it gives us the following error: "The replacement is longer than original and shortening is not allow. impossible to continue"

Any idea what seams the problem?

Note that we can't access http://yourmoodlesite.org/admin/tool/replace/index.php

Average of ratings: -
In reply to Mario Gharib

Re: Moodle Migration

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

Firstly, it's not absolutely vital to do this. You may just have a few broken  images or other internal links. 

Your search and replace links look quite unlikely to me. I would normally expect something more like ('moodle2.2' seems like a very odd hostname - or even part of one)


php admin/tool/replace/cli/replace.php --search=//moodle.mydomain.ac.uk --replace=//testsite.mydomain.ac.uk

In reply to Mario Gharib

Re: Moodle Migration

by Emma Richardson -
Picture of Documentation writers Picture of Particularly helpful Moodlers Picture of Plugin developers

If you can't access the page, then you probably haven't changed your config.php file to reflect the new moodle site. That needs to be done first.  

I am not sure if the dash is causing you an issue or not but I would suggest removing that...

In reply to Mario Gharib

Re: Moodle Migration

by Ken Task -
Picture of Particularly helpful Moodlers

There's another way to change the URL ... you had to get a mysqldump of the DB from the production server.   Edit that mysqldump sql file with an editor that has search and replace ... like nano.   Search and replace there will allow (won't be restircted) searching for

'http://currentproductionFQDN/' with 'http://testFQDN/'.

Is the current production site running https?

There's also another way without having to have a test.FQDN at all ... thus no need to do search and replace on the test site.

In the test IP address set up a virtual apache that uses the *same* FQDN.   Since the test server has a different IP address there is NO conflict getting server to the network, it's a DNS conflict issue.    So once you have the virtual apache configured on the test box using the SAME FQDN, edit the 'hosts' file on the workstation to be used to test the upgrade.  Also edit the /etc/hosts file on the test server.

Easy to do on a Mac or Linux box ... a little harder on Windows but could be done.

On all systems Mac/Linux/Windows, workstations check the host file before using true DNS.   So on the workstation being used make an entry that associates the IP address of the test server with the true FQDN of the site.

Example of addtion to hosts file  (which is real IF the IP address were correct ... changed here to obscure):

208.95.61.20 dev.visd.net dev

Doing a dig for dev.visd.net in DNS returns nothing.   But workstation that has the correct entry in the hosts file can access the site just fine and do the test upgrades without issue.

BTW, if one can do the above, one can also use rsync from production to testdev server for all things ... code, datadirectory and the DB files. *And* there is no need to do anything on the test environment box like search/replace NOR changing config.php.

Have personally used this method (call it 'stealth') and have been able to test in less time + don't have to 'disturb' the DNS administrator with requesting a new DNS entry that should be removed after the production site has been upgraded.

'spirit of sharing', Ken