Note: You are currently viewing documentation for Moodle 3.11. Up-to-date documentation for the latest stable version of Moodle may be available here: Database transfer.

Database transfer: Difference between revisions

From MoodleDocs

(Additional tools may be found elsewhere in the admin settings)

No edit summary
No edit summary
 
(9 intermediate revisions by 5 users not shown)
Line 4: Line 4:
The tool is currently classed as an experimental feature and may be found in ''Settings > Site administration > Development > Experimental > Database migration''. There is also a command line script in ''admin/tool/dbtransfer/cli/migrate.php''.
The tool is currently classed as an experimental feature and may be found in ''Settings > Site administration > Development > Experimental > Database migration''. There is also a command line script in ''admin/tool/dbtransfer/cli/migrate.php''.


The dbtransfer tool uses the XMLDB schema definitions  from Moodle and installed plugins to retrieve the data from one database and transfer it another. If there is any object in the current database (columns, tables,...) not included in the XMLDB schema the dbtransfer won't be executed until these objects are removed.
The dbtransfer tool uses the XMLDB schema definitions  from Moodle and installed plugins to retrieve the data from one database and transfer it another.
 
Some troubles you may find when using this tool:
 
* If there is any object in the current database (columns, tables,...) not included in the XMLDB schema or the other way around the dbtransfer won't be executed until these objects are removed (this may happen if Moodle has been upgraded from earlier versions, if some plugin hasn't been correctly uninstalled...).
* If there is some wrong encoded data in the current database the transfer will crash; in that case find and fix the troublemaking data and launch de dbtranfer tool again.
* If you are trying to migrate a big instance it will take a while, and there can be set some timeout (database, PHP, Apache) that can break the migration.
 
==CLI Database Transfer==
 
* put your original plateform in [[Maintenance_mode]]
* disable [[Cron]] to avoid writing in database during the process
* execute the script with this command  :
 
<code>sudo -u www-data /usr/bin/php /path/to/moodle/admin/tool/dbtransfer/cli/migrate.php --dbtype='pgsql' --dbhost='x.x.x.x' --dbname='moodleDbName' --dbuser='moodleUser' --dbpass='***' --dbport=5432 --prefix='mdl_' --dbsocket='/var/run/postgresql'</code>
 
For more information, type <code>sudo -u www-data /usr/bin/php /path/to/moodle/admin/tool/dbtransfer/cli/migrate.php --help</code>
 
Depending on the size of your database, the process may take several hours.


==See also==
==See also==
Line 14: Line 32:
* [http://moodle.org/mod/forum/discuss.php?d=206759 Where did dbtransfer.php go?]
* [http://moodle.org/mod/forum/discuss.php?d=206759 Where did dbtransfer.php go?]


{{stub}}
[[es:Transferencia de la BasedeDatos]]
[[de:Datenbank-Transfer]]
[[fr:Transfert de base de données]]

Latest revision as of 08:10, 1 September 2020

The database transfer tool enables an administrator to migrate their Moodle site from one database to another, for example from MySQL to Postgres.

The tool is currently classed as an experimental feature and may be found in Settings > Site administration > Development > Experimental > Database migration. There is also a command line script in admin/tool/dbtransfer/cli/migrate.php.

The dbtransfer tool uses the XMLDB schema definitions from Moodle and installed plugins to retrieve the data from one database and transfer it another.

Some troubles you may find when using this tool:

  • If there is any object in the current database (columns, tables,...) not included in the XMLDB schema or the other way around the dbtransfer won't be executed until these objects are removed (this may happen if Moodle has been upgraded from earlier versions, if some plugin hasn't been correctly uninstalled...).
  • If there is some wrong encoded data in the current database the transfer will crash; in that case find and fix the troublemaking data and launch de dbtranfer tool again.
  • If you are trying to migrate a big instance it will take a while, and there can be set some timeout (database, PHP, Apache) that can break the migration.

CLI Database Transfer

  • put your original plateform in Maintenance_mode
  • disable Cron to avoid writing in database during the process
  • execute the script with this command  :

sudo -u www-data /usr/bin/php /path/to/moodle/admin/tool/dbtransfer/cli/migrate.php --dbtype='pgsql' --dbhost='x.x.x.x' --dbname='moodleDbName' --dbuser='moodleUser' --dbpass='***' --dbport=5432 --prefix='mdl_' --dbsocket='/var/run/postgresql'

For more information, type sudo -u www-data /usr/bin/php /path/to/moodle/admin/tool/dbtransfer/cli/migrate.php --help

Depending on the size of your database, the process may take several hours.

See also

  • MDL-34441 finish dbtransfer tool implementation

Using Moodle forum discussions: