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

Moodle Migration

Aus MoodleDocs
Wechseln zu:Navigation, Suche


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

Manchmal kann es nötig sein, dass Sie mit Ihrer Moodle-Site auf einen neuen Server umziehen müssen, z.B. wenn Sie von einem Provider auf einen eigenen Server wechseln.

Hinweis: Vergessen Sie nicht, alle serverspezifischen Einträge in der Moodle-Konfigurationsdatei config.php anzupassen.


Migration einer Moodle-Site - Methode 1

Bei dieser Methode ziehen Sie eine vollständige Moodle-Site von einem Server auf einen anderen um. Wenn sich die Domain bzw. die IP-Adresse ändert, sind folgende Schritte nötig:

  • Wartungsmodus einschalten: Schalten Sie Ihre aktuelle Moodle-Site in den Wartungsmodus, damit keine weiteren Änderungen in der Moodle-Datenbank erfolgen können. Stellen Sie sicher, dass sich auch keine Administrator/innen anmeldungen und Änderungen vornehmen (da diese vom Wartungsmodus nicht betroffen sind).
  • Moodle-Datenbank sichern: Sichern Sie die Moodle-Datenbank wie in den Artikeln Aktualisierung von Moodle bzw. Sicherung der Moodle-Installation beschrieben. Sie erhalten eine Textdatei, die den MySQL Dump enthält.
  • Moodle-Code kopieren: Sie müssen alle PHP-Skripte von Moodle auf den neuen Server kopieren. Aktualisieren Sie den Code auf die neueste Version, wenn möglich.
  • $CFG->wwwroot ändern: Ändern Sie die Variable $CFG->wwwroot in der Moodle-Konfigurationsdatei config.php auf dem neuen Server.
  • Moodle-Datenverzeichnis kopieren (moodledata): Kopieren Sie den kompletten Inhalt des Moodle-Datenverzeichnisses (siehe Variable $CFG->dataroot in der Moodle-Konfigurationsdatei) in das neue Moodle-datenvrezeichnis auf dem neuen Server.
  • Moodledata-Vrezichnisrechte prüfen: Prüfen Sie, dass die Rechte im neuen Moodle-Datenverzeichnis auf dem neuen Server dieselben sind, wie auf dem alten Server. Prüfen Sie die Variable $CFG->dataroot in der Moodle-Konfigurationsdatei config.php auf dem neuen Server.
  • Moodle URL ändern: Wenn sich die URL der Moodle-Site auf dem neuen Server geändert hat, müssen Sie diese Änderung in der Moodle-Datenbank auf dem neuen Server eintragen. Das betrifft alle Links zu Grafiken, Bildern, Dateien usw., die als absolute Links gespeichert sind (diese verweisen auf die alte Adresse, die in $CFG->wwwroot angegeben ist). Wenn Sie die alte Datenbank (mit den alten Links) in eine neue Datenbank auf dem neuen Server hochladen, funktionieren diese absoluen Links nicht mehr. Um die Links für den neuen Server anzupassen, gehen Sie wie folgt vor:
(a) Die erste Methode verwendet das Moodle-Skript replace.php. Rufen Sie im Browser folgende Adresse auf: yourserver.com/admin/tool/replace/index.php.
Geben Sie die URL des alten Servers und des neuen Servers in den entsprechenden Textfeldern ein und starten Sie das Skript. Sie müssen auch alle gecachten Links löschen - am besten, indem Sie den Webserver neu starten.
(b) Bei der zweiten Methode sichern Sie die Moodle-Datenbank und ersetzen dann in dem MySQL-Dump-Textdatei mittels der Suchen&Ersetzen Funktionalität Ihres bevorzugten Texteditors die alte Server-URL durch die neue Server-URL. Der entsprechende Befehl im sed lautet:
#sed -e 's/oldserver.com/newserver.com/g' oldmysqldump.sql > newmysqldump.sql
Danach stellen Sie aus der geänderten MySQL-Dump-Textdatei die Datenbank auf dem neuen Server wieder her.
  • Migration testen: Testen Sie die neue Moodle-Site, indem Sie die neue Server-URL im Browser aufrufen. Prüfen Sie einige/alle Links und schalten Sie dann in der neuen Site den Wartungsmodus wieder aus.

Siehe auch migrating Moodle's data directory on a Windows system - Diskussionsbeitrag auf moodle.org.

Migration einer Moodle-Site - Methode 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.

It mean that that you must not open the

http://example.domain/moodle/admin

webpage yet.

  • 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/

On the new server you must to setup permissions on moodledata directory and it's subdirectories and files.

Say, on a Debian operating system one can run the command:

hostname:/var/lib# chown www-data:www-data -R moodle/
  • 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 the Search and replace admin tool to search and replace the old uri for the new.

Say:

Search and replace text throughout the whole database

Search whole database for: the.old.moodle.uri

Replace with this string: the.new.moodle.uri

  • 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.

Weitere Punkte

Changed URL image links set to old site

So you built your Moodle Server with a http//192.168.0.1/Moodle address. Then you changed the URL for your site to http://OurMoodle.org/Moodle . You changed the Moodle config file so the CFGs point to the new paths. But your images point to the old url.

One simple, quick solution. Login as admin and put <nowiki>OurMoodle.org/admin/tool/replace/index.php or in older versions http://OurMoodle.com/admin/replace.php in your browser address bar. Use the two form boxes to change http://192.168.0.1/ to http://OurMoodle.org/ .</nowiki>

Moodle aktualisieren

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.

Einen einzelnen Kurs auf einem anderen Server wiederherstellen

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 Änderungen

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.

Interner und externer Zugriff

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

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