Migrazione di Moodle: differenze tra le versioni

Da MoodleDocs.
Riga 31: Riga 31:


===Copiare la directory moodledata dal vecchio server al nuovo server===
===Copiare la directory moodledata dal vecchio server al nuovo server===
Copiare il contenuto della directory dei dati (controllare il valore in <code>$CFG->dataroot</ code>) sul nuovo server. Potrebbe contenere tantissimi dati, quindi prendere in considerazione l'utilizzo di un buon strumento di copia dei dati come {{en}} [https://rsync.samba.org/ rsync]. Se si utilizza un client FTP, il trasferimento della cartella <code>filedir</ code> deve essere in modalità '''BINARY''' altrimenti i file verranno danneggiati durante il processo.
Copiare il contenuto della directory dei dati (controllare il valore in <code>$CFG->dataroot</code>) sul nuovo server. Potrebbe contenere tantissimi dati, quindi prendere in considerazione l'utilizzo di un buon strumento di copia dei dati come {{en}} [https://rsync.samba.org/ rsync]. Se si utilizza un client FTP, il trasferimento della cartella <code>filedir</ code> deve essere in modalità '''BINARY''' altrimenti i file verranno danneggiati durante il processo.


{{Nota|Non è necessario copiare il contenuto delle directory /moodledata/cache, /moodledata/localcache, /moodledata/sessions, /moodledata/temp o /moodledata/trashdir. Omettere questi file ridurrà sostanzialmente il tempo di trasferimento.}}
{{Nota|Non è necessario copiare il contenuto delle directory /moodledata/cache, /moodledata/localcache, /moodledata/sessions, /moodledata/temp o /moodledata/trashdir. Omettere questi file ridurrà sostanzialmente il tempo di trasferimento.}}

Versione delle 09:41, 19 dic 2018

Attenzione: Pagina in costruzione


Ci possono essere momenti in cui è necessario spostare il sito Moodle da un server a un altro. Ad esempio, quando si sposta un sito Moodle dal server condiviso del servizio di hosting a un server dedicato.

Metodo consigliato

Comporta lo spostamento di un intero sito da un server all'altro. Se si sta modificando il dominio/l'indirizzo IP sul nuovo server, occorre seguire i passaggi che seguono.

Attivare la modalità manutenzione

Mettere il sito Moodle in modalità manutenzione da Amministrazione del sito > Server > Manutenzione per impedire ulteriori aggiunte al database Moodle. Non consentire agli Amministratori di accedere durante la migrazione poiché non sono soggetti ai blocchi attivi quando il sistema è in manutenzione.

Eseguire il backup del database Moodle sul vecchio server

Il modo corretto per eseguire il backup del database dipende dal sistema di database che si sta utilizzando. Le istruzioni seguenti sono un modo per eseguire il backup di un database MySQL. Un'altra opzione potrebbe essere quella di utilizzare uno strumento come phpMyAdmin per eseguire manualmente un backup. La documentazione del database sarà più specifica. Ci sono molti modi per fare i backup. Ecco uno schema di un piccolo script che è possibile eseguire dalla riga di comando su Unix per eseguire il backup del database:

cd /my/backup/directory
mv moodle-database.sql.gz moodle-database-old.sql.gz
mysqldump -h example.com -u myusername -p'mypassword' -C -Q -e --create-options mydatabasename > moodle-database.sql

Se si scrive solo -p, la password verrà richiesta.

Ripristinare il backup del database sul nuovo server

Copiare i file di backup del database sul nuovo server e ripristinarli nel nuovo server di database.

Una volta creato il nuovo database sul nuovo server:

mysql -p new_database < moodle-database.sql

Per altri database, seguire le istruzioni per ripristinare un backup.

Copiare la directory moodledata dal vecchio server al nuovo server

Copiare il contenuto della directory dei dati (controllare il valore in $CFG->dataroot) sul nuovo server. Potrebbe contenere tantissimi dati, quindi prendere in considerazione l'utilizzo di un buon strumento di copia dei dati come (EN) rsync. Se si utilizza un client FTP, il trasferimento della cartella filedir</ code> deve essere in modalità BINARY altrimenti i file verranno danneggiati durante il processo.

Nota: Non è necessario copiare il contenuto delle directory /moodledata/cache, /moodledata/localcache, /moodledata/sessions, /moodledata/temp o /moodledata/trashdir. Omettere questi file ridurrà sostanzialmente il tempo di trasferimento.


Controllare i permessi dei file dei file copiati. Il server web necessita di accesso in lettura e scrittura.

Copy the Moodle code from the old server to the new server

You will need to copy the Moodle code itself to the new server (this is the Moodle folder found in your webroot folder e.g. /var/www or public_html).

Check the file permissions of the copied files. The web server needs read access.

Update config.php with the URL of the new server

If the migration will move Moodle to a new URL, then update $CFG->wwwroot in config.php to point to the new location.

Also check the other properties there. Is the path $CFG->moodledata still correct? Do the database connection settings need to be changed?

Test the copied site

You should now be able to log into the new site as admin, and verify that most things are working.

Update links containing wwwroot in the database

The one thing we have not fixed is any internal links stored in the database. To fix these use the Search and replace tool buy going to {wwwroot}/admin/tool/replace/index.php.

Enter the url for your old server (http://oldserver.com/) and new server (http://newserver.com/) and it will fix any links stored in the database.

Take the site out of maintenance mode

Test the migration some more, then when you are satisfied, remember to take the site out of maintenance mode.

Quick and hacky method

If you have shell access on both servers, here is a quick command-line based method.

  • Set up a new empty database on the new server.
  • Place your existing Moodle site into maintenance mode.
  • Login to shell on the old existing server.
  • Use rsync to copy moodledata and public_html or moodle folders (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"
  • Replace any links in the database that contin the full site URL:
#sed -e 's/oldserver.com/newserver.com/g' oldmysqldump.sql > newmysqldump.sql
  • On the new server, update config.php with relevant details where applicable (e.g. database name and user details, the wwwroot and the dataroot).
  • Check ownership and permissions are correct on both moodle code and moodledata directories.
  • Make sure everything is working.

Takes about 15 minutes for a small site. However, transferring several Gigabytes of data for a larger site can take hours depending on your network connection and hard drive read/write speed.

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.

  • If you are switching the ip address from the old server to the new one, you will need to turn off the old server before firing up the new one to avoid ip addressing conflicts and confusion!

Other considerations

Upgrade Moodle at the same time?

While doing the work of migrating Moodle, you might want to upgrade Moodle to the latest version at the same time. On the other hand, if you do that, and something breaks, you won't be sure which change caused the problem, so the more cautious approach is to change one thing at a time, and test in between to verify that all is well.

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.

reCAPTCHA

If you migrate to a new domain and have setup Email-based_self-registration, you need to create new API-Keys at google. You will find the explanation and links to google in Email-based_self-registration.

Vedere anche

Any questions?

Please post in the Installing and upgrading help forum on moodle.org