Hinweis: Sie sind auf den Seiten der Moodle 1.9 Dokumentation. Die Dokumentation der aktuellsten Moodle-Version finden Sie hier: Moodle-Migration.

Moodle-Migration: Unterschied zwischen den Versionen

Aus MoodleDocs
Wechseln zu:Navigation, Suche
(Die Seite wurde neu angelegt: „{{Zum Übersetzen}} Siehe en:Moodle migration Category:Administrator en:Moodle migration“)
 
Keine Bearbeitungszusammenfassung
Zeile 1: Zeile 1:
{{Zum Übersetzen}}
{{Zum Übersetzen}}
Siehe [[:en:Moodle migration]]
Siehe [[:en:Moodle migration]]
Manchmal ist es erforderlich, mit einer Moodle-Installation von einem Server zu einem anderen umzuziehen. Dieser Vorgang wird als [[Moodle-Migration]] bezeichnet. Einer der häufigsten Fehler, der bei diesem Prozess gemacht wird, ist folgender: Es wird nicht daran gedacht, Anpassungen in der [[Konfigurationsdatei|Moodle-Konfigurationsdatei]] ''config.php'' vorzunehmen.


==Moodle-Migration - Methode 1==
Wenn sich der Domain-Name und die IP-Adresse des Moodle-Servers ändert, sind folgende Schritte zu erledigen:
* '''Wartungsmodus''': Schalten Sie Ihre aktuelle Moodle-Installation (auf dem alten Server) in den [[Wartungsmodus]], um zu verhindern, das neue Einträge in der [[Moodle-Datenbank]] vorgenommen werden. Auch Administratoren dürfen sich nicht mehr auf der alten Installation anmelden!
* '''Sicherung der Moodle-Datenbank''': Do this by following the instructions in the [[Upgrading | upgrading Moodle]] or [[Site backup]] page. This will give you a text file containing the mysql dump.
* '''Copy the Moodle software'''. You will need to copy the Moodle code itself to the new server - upgrade the code to the latest version if you can.
* '''Change <code>$CFG->wwwroot</code>'''. In your (possibly new) Moodle directory, change the <code>$CFG->wwwroot</code> variable in the ''config.php'' file for the new server.
* '''Copy data directory contents (moodledata)'''. Copy the contents of your data directory (check for the value in <code>$CFG->dataroot</code>) to the new server.
* '''Review moodledata permissions'''. Check also that permissions remain the same on the new dataroot folder and change the value if you have changed its location on the new server.
* '''Change your Moodle URL'''. If you have a new URL, you'll need to change this in the Moodle database to the new server. This is needed as links to pictures, files, etc are stored as absolute links and will reference the old <code>$CFG->wwwroot</code> value. So when loading a mysql backup dump of the Moodle server into mysql on another server the absolute referenced links will be broken. There are two methods of doing this:
:(a) The first method changes the Moodle URL using the Moodle script ''replace.php'' while your site is currently running just before you backup the Moodle database. Point your browser to <nowiki>http://yourserver.com/admin/replace.php</nowiki>
:Enter the url for your old server (<nowiki>http://oldserver.com/</nowiki>) and new server (<nowiki>http://newserver.com/</nowiki>) and it will fix the mysql tables. You will also need to clear out any cached links by restarting your webserver. Now, take another backup of the Moodle database - this one will have the correct URLs.
:(b) The second method is to backup the Moodle database first, then use the search and replace feature of your text editor (or use a unix tool like sed) to replace the old URL with the new one in the mysql backup file. Here is an example sed command:
: <code>#sed -e 's/oldserver.com/newserver.com/g' oldmysqldump.sql > newmysqldump.sql</code>
:''TIP:'' You may want to check the mysqldump file to see how the old server was referenced.
:After changing the URL, restore the mysql database
* '''Test the migration'''. To test the new install, access Moodle using your browser and the new server's URL. When you have tested that a number of links in the courses work, take the new Moodle site out of maintenance mode.
'''See also''': Forum discussion on [http://moodle.org/mod/forum/discuss.php?d=85812 migrating Moodle's data directory on a Windows system].
==Migrating a complete Moodle site - method 2==
Do you have shell access on both servers? If so, the following method is a very quick and efficient method to migrate a Unix based site.
It is also useful for creating snapshots or test sites.
*Set up a new empty database on the '''new''' server.
*Place your Moodle site into maintenance mode.
*Login to shell on the '''old''' server.
*Use rsync to copy '''moodledata''' and '''public_html''' (or whatever directory your Moodle install is in) to the new server - execute (replacing caps with your details; SOURCE = the directory you want to copy) for each directory:
::<code>rsync -av -e ssh SOURCE/ USERNAME@NEW_SERVER.COM:/PATH/TO/DESTINATION/</code>
*Dump existing database and move and import into database on new server by executing:
::<code>mysqldump --allow-keywords --opt -uMySQL_USERNAME -pPASSWORD DATABASE | ssh USER@DOMAIN "mysql -uMySQL_USERNAME -pPASSWORD DATABASE"</code>
*On the '''new server''', update '''config.php''' with relevant details.
*To fix any internal Moodle links, login to your "new" Moodle install on your new server and use '''admin/replace.php''' to search and replace the old uri for the new.
*Make sure everything is working.
Takes about 15 minutes.
When you are happy all has gone well, set up redirects/make DNS changes if required, take new site out of maintenance mode and "switch off" old site.
==Other points to consider==
===Upgrade Moodle===
When migrating Moodle it is often a good idea to take the opportunity to upgrade Moodle to the latest version. If you manage your own server, follow the instructions in [[Upgrading | upgrading moodle]], otherwise check if your host can upgrade for you.
===Restoring a single course across servers===
You may need to restore a single course from an old site to a new one, especially if you are testing the migration. When restoring a Moodle backup file to Moodle on a different server than the one used to create the backup, the absolute referenced links to files maybe broken. To fix this problem open the ''backup-coursename.zip'' file and edit the ''moodle.xml'' file replacing links with <code>$@FILEPHP@$</code>.
For example, replace <nowiki>http://yourserver.com/file.php/243/</nowiki> with <code>$@FILEPHP@$</code>
When the file is restored it will use the correct file path for the new course.
===DNS & Masquerading changes===
You may have had to change the DNS entries for the new Moodle site. If you have done so, it will take some time for the changes to replicate, so be patient. If your server is located behind a firewall, you may also have to change your firewall rules to allow access to the new server. See the [[Masquerading | masquerading docs]].
===Internal and external access===
If you have a set up where your Moodle site can be accessed via a network and via the internet, ensure you check that the new site can be accessed internally and externally. 
==Siehe auch==
* [[Sicherung der Moodle-Installation]]
* [[Sicherung und Wiederherstellung FAQ]]
* [http://www.youtube.com/watch?v=sFCXvRx20Bs Moving Moodle to a new server video] - Video zum Umzug von Moodle auf einen neuen Server
Diskussionsbeiträge im Kurs ''Using Moodle'' auf moodle.org:
* [http://moodle.org/mod/forum/discuss.php?d=62959 Changing Moodle URL]
* [http://moodle.org/mod/forum/discuss.php?d=57477 Changing site address]
* [http://moodle.org/mod/forum/discuss.php?d=76704 Upgrading whilst migrating]
* [http://moodle.org/mod/forum/discuss.php?d=65450 Internal and external access]
* [http://moodle.org/mod/forum/discuss.php?d=111807 Migrated Moodle to New Server But Can't Login]
[[Category:Installation]]
[[Category:Administrator]]
[[Category:Administrator]]
[[en:Moodle migration]]
[[en:Moodle migration]]

Version vom 3. Februar 2010, 14:23 Uhr

Baustelle.png Diese Seite ist noch nicht vollständig übersetzt.

Siehe en:Moodle migration Manchmal ist es erforderlich, mit einer Moodle-Installation von einem Server zu einem anderen umzuziehen. Dieser Vorgang wird als Moodle-Migration bezeichnet. Einer der häufigsten Fehler, der bei diesem Prozess gemacht wird, ist folgender: Es wird nicht daran gedacht, Anpassungen in der Moodle-Konfigurationsdatei config.php vorzunehmen.

Moodle-Migration - Methode 1

Wenn sich der Domain-Name und die IP-Adresse des Moodle-Servers ändert, sind folgende Schritte zu erledigen:

  • Wartungsmodus: Schalten Sie Ihre aktuelle Moodle-Installation (auf dem alten Server) in den Wartungsmodus, um zu verhindern, das neue Einträge in der Moodle-Datenbank vorgenommen werden. Auch Administratoren dürfen sich nicht mehr auf der alten Installation anmelden!
  • Sicherung der Moodle-Datenbank: Do this by following the instructions in the upgrading Moodle or Site backup page. This will give you a text file containing the mysql dump.
  • Copy the Moodle software. You will need to copy the Moodle code itself to the new server - upgrade the code to the latest version if you can.
  • Change $CFG->wwwroot. In your (possibly new) Moodle directory, change the $CFG->wwwroot variable in the config.php file for the new server.
  • Copy data directory contents (moodledata). Copy the contents of your data directory (check for the value in $CFG->dataroot) to the new server.
  • Review moodledata permissions. Check also that permissions remain the same on the new dataroot folder and change the value if you have changed its location on the new server.
  • Change your Moodle URL. If you have a new URL, you'll need to change this in the Moodle database to the new server. This is needed as links to pictures, files, etc are stored as absolute links and will reference the old $CFG->wwwroot value. So when loading a mysql backup dump of the Moodle server into mysql on another server the absolute referenced links will be broken. There are two methods of doing this:
(a) The first method changes the Moodle URL using the Moodle script replace.php while your site is currently running just before you backup the Moodle database. Point your browser to http://yourserver.com/admin/replace.php
Enter the url for your old server (http://oldserver.com/) and new server (http://newserver.com/) and it will fix the mysql tables. You will also need to clear out any cached links by restarting your webserver. Now, take another backup of the Moodle database - this one will have the correct URLs.
(b) The second method is to backup the Moodle database first, then use the search and replace feature of your text editor (or use a unix tool like sed) to replace the old URL with the new one in the mysql backup file. Here is an example sed command:
#sed -e 's/oldserver.com/newserver.com/g' oldmysqldump.sql > newmysqldump.sql
TIP: You may want to check the mysqldump file to see how the old server was referenced.
After changing the URL, restore the mysql database
  • Test the migration. To test the new install, access Moodle using your browser and the new server's URL. When you have tested that a number of links in the courses work, take the new Moodle site out of maintenance mode.

See also: Forum discussion on migrating Moodle's data directory on a Windows system.

Migrating a complete Moodle site - method 2

Do you have shell access on both servers? If so, the following method is a very quick and efficient method to migrate a Unix based site.

It is also useful for creating snapshots or test sites.

  • Set up a new empty database on the new server.
  • Place your Moodle site into maintenance mode.
  • Login to shell on the old server.
  • Use rsync to copy moodledata and public_html (or whatever directory your Moodle install is in) to the new server - execute (replacing caps with your details; SOURCE = the directory you want to copy) for each directory:
rsync -av -e ssh SOURCE/ USERNAME@NEW_SERVER.COM:/PATH/TO/DESTINATION/
  • Dump existing database and move and import into database on new server by executing:
mysqldump --allow-keywords --opt -uMySQL_USERNAME -pPASSWORD DATABASE | ssh USER@DOMAIN "mysql -uMySQL_USERNAME -pPASSWORD DATABASE"
  • On the new server, update config.php with relevant details.
  • To fix any internal Moodle links, login to your "new" Moodle install on your new server and use admin/replace.php to search and replace the old uri for the new.
  • Make sure everything is working.

Takes about 15 minutes.

When you are happy all has gone well, set up redirects/make DNS changes if required, take new site out of maintenance mode and "switch off" old site.

Other points to consider

Upgrade Moodle

When migrating Moodle it is often a good idea to take the opportunity to upgrade Moodle to the latest version. If you manage your own server, follow the instructions in upgrading moodle, otherwise check if your host can upgrade for you.

Restoring a single course across servers

You may need to restore a single course from an old site to a new one, especially if you are testing the migration. When restoring a Moodle backup file to Moodle on a different server than the one used to create the backup, the absolute referenced links to files maybe broken. To fix this problem open the backup-coursename.zip file and edit the moodle.xml file replacing links with $@FILEPHP@$.

For example, replace http://yourserver.com/file.php/243/ with $@FILEPHP@$

When the file is restored it will use the correct file path for the new course.

DNS & Masquerading changes

You may have had to change the DNS entries for the new Moodle site. If you have done so, it will take some time for the changes to replicate, so be patient. If your server is located behind a firewall, you may also have to change your firewall rules to allow access to the new server. See the masquerading docs.

Internal and external access

If you have a set up where your Moodle site can be accessed via a network and via the internet, ensure you check that the new site can be accessed internally and externally.

Siehe auch

Diskussionsbeiträge im Kurs Using Moodle auf moodle.org: