Diferencia entre revisiones de «Migración de Moodle»

De MoodleDocs
Sin resumen de edición
 
(No se muestran 6 ediciones intermedias de otro usuario)
Línea 2: Línea 2:
|docpagetitle = Moodle migration
|docpagetitle = Moodle migration
}}
}}
{{Actualizar}}
 
{{Instalación de Moodle}}
{{Instalación de Moodle}}
Hay ocasiones en las que usted necesita mover su sitio Moodle de un servidor a otro. Por ejemplo, al mover un sitio Moodle desde un servidor en alojamiento compartido hacia un servidor dedicado.
Hay ocasiones en las que usted necesita mover su sitio Moodle de un servidor a otro. Por ejemplo, al mover un sitio Moodle desde un servidor en alojamiento compartido hacia un servidor dedicado.


:''Tip:'' Un error común en la migración es por olvidarse de actualizar los detalles en el archivo [[config.php]] del Moodle migrado
==Método recomendado==
 
Esto involucra el mover un sitio completo desde un servidor hacia otro. Si Usted está cambiando la dirección IP o la del domio al nuevo servidor, necesita realizar estos pasos:
 
===Activar modo de mantenimiento===
 
Ponga su sitio Moodle en [[Modo de mantenimiento]] vía ''Administración del sitio > Servidor > Modo de mantenimiento'' para evitar que haya más adiciones a la base de datos de Moodle. No permita que los administradores ingresen durante la migración, ya que ellos no están afectados por la configuración del modo de mantenimiento.
 
===Respaldar la base de datos de Moodle en el servidor antiguo===
La manera correcta de respaldar tu base de datos depende de cuál sistema de base de datos estés utilizando. Las instrucciones de abajo son la manera para realizar el respaldo en una base de datos con MySQL. Otra opción sería utilizar una herramienta como phpMyAdmin para hacer manualmente el respaldo. La documentación para tu base de datos te dará más opciones. Hay muchas varias maneras para hacer esos respaldos. Aquí está un esquema de una pequeño script que pueden correr en la línea de comandos en UNIX para respaldar la base de datos:
 
<pre>
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
</pre>
If you only write "-p" without your password, you will be prompted for it.
 
=== Restaurar el respaldo de la base de datos al nuevo servidor ===
 
Copy the database back up files to the new server and restore into the new database server.
 
Once you have created the new database on the new server:
 
<pre>mysql -p new_database < moodle-database.sql</pre>


==Migrando un sitio Moodle completo - método 1==
For other databases, follow their instructions for restoring a backup.


This involves moving a whole site from one server to another. If you are changing the domain/IP address to the new server you need to do these steps:
===Copiar moodledata desde el antiguo servidor al nuevo servidor===
* '''Maintenance mode'''. Place your current Moodle site in maintenance mode to prevent any further additions to the Moodle database. Don't let administrators login during the migration as they are not affected by the maintenance mode setting.
* '''Backup your current Moodle database'''. Do this by following the instructions in the [[Actualización | actualizar Moodle]] or [[Respaldo del sitio]] 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>yourserver.com/admin/tool/replace/index.php</nowiki> or in older versions <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.
Copy the contents of your data directory (check for the value in <code>$CFG->dataroot</code>) to the new server. This can be a lot of data, so consider using a good data copying tool like [https://rsync.samba.org/ rsync]. If using an FTP client, the transfer of the <code>filedir</code> folder must be in '''BINARY''' mode or the files will get corrupted in the process.


:(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:
NB: It is not necessary to copy the contents of these directories:
* /moodledata/cache
* /moodledata/localcache
* /moodledata/sessions
* /moodledata/temp
* /moodledata/trashdir
Omitting these files will reduce transfer time substantially.


: <code>#sed -e 's/oldserver.com/newserver.com/g' oldmysqldump.sql > newmysqldump.sql</code>
Check the file permissions of the copied files. The web server needs read and write access.


:''NOTE:'' This second method will not replace text in blocks because they are stored base64 encoded in the database, so any links in blocks will not be fixed. Therefore you should consider using the replace tool after you migrate if you use this second method.
===Copiar el código de Moodle desde el antiguo servidor al nuevo servidor===


:''TIP:'' You may want to check the mysqldump file to see how the old server was referenced.
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).  
: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].


==Migrando un sitio Moodle completo - método  2==
Check the file permissions of the copied files. The web server needs read access.


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.
===Actualizar config.php con la URL del nuevo servidor===
 
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?
 
===Probar el sitio copiado===
 
You should now be able to log into the new site as admin, and verify that most things are working.
 
===Actualizar enlaces que contienen wwwroot en la base de datos===
 
The one thing we have not fixed is any internal links stored in the database. To fix these use the [[Herramienta para buscar y remplazar]] by going to {wwwroot}/admin/tool/replace/index.php.
 
Enter the url for your old server (<nowiki>http://oldserver.com/</nowiki>) and new server (<nowiki>http://newserver.com/</nowiki>) and it will fix any links stored in the database.
 
===Sacar el sitio del modo de mantenimiento===
 
Test the migration some more, then when you are satisfied, remember to take the site out of [[Modo de mantenimiento]].
 
==Método rápido y sucio==
 
If you have shell access on both servers, here is a quick command-line based method.


It is also useful for creating snapshots or test sites.
*Set up a new empty database on the '''new''' server.
*Set up a new empty database on the '''new''' server.
*Place your existing Moodle site into maintenance mode.
*Place your existing Moodle site into maintenance mode.
*Login to shell on the '''old''' existing server.
*Login to shell on the '''old''' existing 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:
*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:
::<code>rsync -av -e ssh SOURCE/ USERNAME@NEW_SERVER.COM:/PATH/TO/DESTINATION/</code>
::<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:
*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>
::<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.
*Replace any links in the database that contin the full site URL:
*To fix any internal Moodle links, login to your "new" Moodle install on your new server and use the [[Herramienta para buscar y remplazar]] admin tool to search and replace the old uri for the new.
::<code>#sed -e 's/oldserver.com/newserver.com/g' oldmysqldump.sql > newmysqldump.sql</code>
*Make sure everything is working.</code>
*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.
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.
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.  


==Otros puntos a considerar==
*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!
===Los enlaces de URL de imágenes configurados hacia el sitio antiguo===
So you built your Moodle Server with a <nowiki>http//192.168.0.1/Moodle</nowiki> address. Then you changed the URL for your site to <nowiki>http://OurMoodle.org/Moodle</nowiki>. You changed the Moodle config file so the CFGs point to the new paths, but your images still point to the old url. 


One simple, quick solution is to use the Replace script in Moodle to fix this. Login as admin and enter  <nowiki>http://OurMoodle.org/admin/tool/replace/index.php</nowiki> in your browser address bar (or  <nowiki>http://OurMoodle.com/admin/replace.php</nowiki> in older versions). Use the two form boxes to change <nowiki>http://192.168.0.1/</nowiki> to <nowiki>http://OurMoodle.org/</nowiki>.
==Otras consideraciones==


This replace function is only supported on Moodle sites that run on MySQL or Postgres databases. See MDL-26597 and MDL-35099.
===¿Actualizar Moodle al mismo tiempo?===


===Actualice Moodle===
Al mismo tiempo que se hace el trabajo de migrar Moodle, Usted podría desear [[Actualización de moodle|actualizar Moodle]] a la versión más reciente al mismo tiempo. Pero, si así lo hiciera y algo se rompiera, no estaría seguro de qué fue lo que causó el problema, por lo que el camino más cauteloso es cambiar una cosa a la vez, y probar entre cambios para verificar que todo esté bien.


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 [[Actualización | actualizar moodle]], otherwise check if your host can upgrade for you.
===DNS y cambios en enmascaramiento===


===Restaurando un sólo curso entre servidores===
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 [[Enmascaramiento| documentación sobre enmascaramiento]].


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>.
===Acceso interno y externo===
 
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 y cambios en enmascaramiento===
Si Usted tiene un sistema en donde su sitio Moodle puede ser accedido vía una red interna y vía el Internet, asegúrese de revisar que el nuevo sitio puede ser accedido internamente y externamente.


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. Vea [[Enmascaramiento]].
===reCAPTCHA===
Si Usted migra hacia un nuevo dominio y ha configurado el [[Auto-registro basado en Email]], Usted necesitará crear nuevas claves API en Google. Usted encontrará la explicación y enlaces hacia Google en [[Auto-registro basado en Email]].


===Acceso interno y externo===
==¿Preguntas?==


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.
Por favor publíquelas:
* en idioma inglés en el  [http://moodle.org/mod/forum/view.php?id=28 Installing and upgrading help forum] en moodle.org
* en español en el [https://moodle.org/mod/forum/view.php?id=691 foro sobre Instalación y Actualización] en moodle.org


==Vea también==
==Vea también==


* [[Copia de seguridad del sitio]]
* [[Respaldo del sitio]]
* [[Restauración del sitio]]
* [[Restauración del sitio]]
* [[Respaldo y restauración FAQ]]
* [[Respaldo y restauración FAQ]]
Enlaces antiguos:
* [http://www.youtube.com/watch?v=sFCXvRx20Bs Moving Moodle to a new server video]
* [http://www.youtube.com/watch?v=sFCXvRx20Bs Moving Moodle to a new server video]
* [http://tracker.moodle.org/browse/MDL-35099 Convert hidden search/replace script into a proper core admin tool] Tracker issue
* [http://tracker.moodle.org/browse/MDL-35099 Convert hidden search/replace script into a proper core admin tool] Tracker issue

Revisión actual - 18:17 16 jul 2019

Nota: Esta es una traducción de una página de la documentación en idioma Inglés (Docs), que se considera particularmente importante, y que en su versión original se actualiza frecuentemente. Por ello, se le recomienda que revise la página original en idioma inglés: Moodle migration.


Hay ocasiones en las que usted necesita mover su sitio Moodle de un servidor a otro. Por ejemplo, al mover un sitio Moodle desde un servidor en alojamiento compartido hacia un servidor dedicado.

Método recomendado

Esto involucra el mover un sitio completo desde un servidor hacia otro. Si Usted está cambiando la dirección IP o la del domio al nuevo servidor, necesita realizar estos pasos:

Activar modo de mantenimiento

Ponga su sitio Moodle en Modo de mantenimiento vía Administración del sitio > Servidor > Modo de mantenimiento para evitar que haya más adiciones a la base de datos de Moodle. No permita que los administradores ingresen durante la migración, ya que ellos no están afectados por la configuración del modo de mantenimiento.

Respaldar la base de datos de Moodle en el servidor antiguo

La manera correcta de respaldar tu base de datos depende de cuál sistema de base de datos estés utilizando. Las instrucciones de abajo son la manera para realizar el respaldo en una base de datos con MySQL. Otra opción sería utilizar una herramienta como phpMyAdmin para hacer manualmente el respaldo. La documentación para tu base de datos te dará más opciones. Hay muchas varias maneras para hacer esos respaldos. Aquí está un esquema de una pequeño script que pueden correr en la línea de comandos en UNIX para respaldar la base de datos:

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

If you only write "-p" without your password, you will be prompted for it.

Restaurar el respaldo de la base de datos al nuevo servidor

Copy the database back up files to the new server and restore into the new database server.

Once you have created the new database on the new server:

mysql -p new_database < moodle-database.sql

For other databases, follow their instructions for restoring a backup.

Copiar moodledata desde el antiguo servidor al nuevo servidor

Copy the contents of your data directory (check for the value in $CFG->dataroot) to the new server. This can be a lot of data, so consider using a good data copying tool like rsync. If using an FTP client, the transfer of the filedir folder must be in BINARY mode or the files will get corrupted in the process.

NB: It is not necessary to copy the contents of these directories:

  • /moodledata/cache
  • /moodledata/localcache
  • /moodledata/sessions
  • /moodledata/temp
  • /moodledata/trashdir

Omitting these files will reduce transfer time substantially.

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

Copiar el código de Moodle desde el antiguo servidor al nuevo servidor

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.

Actualizar config.php con la URL del nuevo servidor

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?

Probar el sitio copiado

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

Actualizar enlaces que contienen wwwroot en la base de datos

The one thing we have not fixed is any internal links stored in the database. To fix these use the Herramienta para buscar y remplazar by 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.

Sacar el sitio del modo de mantenimiento

Test the migration some more, then when you are satisfied, remember to take the site out of Modo de mantenimiento.

Método rápido y sucio

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!

Otras consideraciones

¿Actualizar Moodle al mismo tiempo?

Al mismo tiempo que se hace el trabajo de migrar Moodle, Usted podría desear actualizar Moodle a la versión más reciente al mismo tiempo. Pero, si así lo hiciera y algo se rompiera, no estaría seguro de qué fue lo que causó el problema, por lo que el camino más cauteloso es cambiar una cosa a la vez, y probar entre cambios para verificar que todo esté bien.

DNS y cambios en enmascaramiento

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 documentación sobre enmascaramiento.

Acceso interno y externo

Si Usted tiene un sistema en donde su sitio Moodle puede ser accedido vía una red interna y vía el Internet, asegúrese de revisar que el nuevo sitio puede ser accedido internamente y externamente.

reCAPTCHA

Si Usted migra hacia un nuevo dominio y ha configurado el Auto-registro basado en Email, Usted necesitará crear nuevas claves API en Google. Usted encontrará la explicación y enlaces hacia Google en Auto-registro basado en Email.

¿Preguntas?

Por favor publíquelas:

Vea también

Enlaces antiguos:

Discusiones en foros sobre uso de Moodle: