Postgres Migration

March 28, 2008 – 17:20

Prepare for postgres migration.

Moodle forum post on migration: the idea is to let moodle create an empty pg database and then upload the mysql data (which is edited with some grep to overcome differences).

Continued from this post.

Have to setup a new dedicated server for a client. Decided to go with postgreSQL for several reasons. So downloaded the latest version of mysql2pgsql.

  • dumped mysql database data with: mysqldump --skip-opt --single-transaction -c -t -u moodleuser -p moodle_bd > moodle_name_my_ct.sql (only data)
  • converted mysql dump to pgdump with: cat moodle_name_my_ct.sql | sed -e 's/`//g' > insert_pg.sql
  • optionally you can skip the log tables by piping it trough something like this: grep -v '[prefix]_log' depending on where in the sequence you put the grep
  • switched to postgres user
  • psql -d moodle_db -U moodleuser
  • \set ON_ERROR_STOP on (in appr database)
  • \o /path/to/error.log (optional)
  • BEGIN;
  • \i /path/to/dump.sql
  • COMMIT;

And big succes!

Sorry, comments for this entry are closed at this time.