Can I backup a course from Mysql and restore to Postgres?

Can I backup a course from Mysql and restore to Postgres?

by Walter Byrd -
Number of replies: 8

Or vice-versa?

I would think I could. But does anybody know?


Average of ratings: -
In reply to Walter Byrd

Re: Can I backup a course from Mysql and restore to Postgres?

by Colin Fraser -
Picture of Documentation writers Picture of Testers
AFAIK, the structures of the database are the same, so there is no problem... but having said that, the last time I was involved in such a change, from MySQL to Postgres, was about v2.3, I think, and it was the whole database. The tech guys just did a data dump/backup of the of the entire database and uploaded the file to the new one, went like a dream I was told, but I don't know what prep work was done before hand, so there's no reason why that shouldn't happen. Essentially, the database structure should be the same so if the dump is in an SQL format, which it should be, should translate properly. Postgres' handling routines are likely different to MySQL, I understand, but it is compliant with the latest SQL standards.
Average of ratings: Useful (1)
In reply to Colin Fraser

Re: Can I backup a course from Mysql and restore to Postgres?

by Walter Byrd -
Thank you. But what I meant is a little different. I was posting about a standard course backup into a Moodle XML (.mbz) file. I should have been more explicit.

If I were on Moodle site A, which uses MySQL, and backed up a course to a .mbz file; then restored the course to Moodle site B, which uses PostgreSQL; would I run into any trouble because I am backing up from one type of database, and restoring into another?

I do not think I would have any trouble. But I would like to make sure.
In reply to Walter Byrd

Re: Can I backup a course from Mysql and restore to Postgres?

by Dave Balch -
The database any particular Moodle site uses will not affect .mbz backups, which are designed for reliable transfer of courses between Moodles .
Average of ratings: Useful (2)
In reply to Dave Balch

Re: Can I backup a course from Mysql and restore to Postgres?

by Walter Byrd -
I have a moodle 3.7.7 installation on my home server using postgres, and an online moodle 3.7.7 using mysql. I am having trouble backing up, and restoring files, between them. When I backup from my online site, and try to restore to my home server, I get a "Database Error" sometimes.
I have the studentquiz plugin on both sites. This seems to only happen when I try to backup and restore courses that use that plugin.
I don't know if it's because I have different database applications, or something else.
In reply to Walter Byrd

Re: Can I backup a course from Mysql and restore to Postgres?

by Thorsten Bartel -
Picture of Core developers

Hey Walter,

I suspect your Postgres and MySQL installations may be using different character sets (collations) for their databases.
Especially MySQL has a nasty habit of using "UTF8" as its standard collation, which unfortunately supports only a small subset of unicode characters (3 bytes instead of 4). Check the collation of your MySQL database by executing the following SQL queries:

USE db_name;
SELECT @@character_set_database, @@collation_database;
The following problems could result from faulty collations (among others):
- Due to identical field lengths but 3 byte characters in one and 4 byte characters in the other database, entries exported from one database could be too long to import in the other one.
- Certain unicode special characters from the exported database cannot be imported into the other database.

Cheers

Average of ratings: Useful (2)
In reply to Thorsten Bartel

Re: Can I backup a course from Mysql and restore to Postgres?

by Leon Stringer -
Picture of Core developers Picture of Particularly helpful Moodlers

You should check the MySQL database is set to the recommended character encoding as Thorsten suggests, a warning is shown in the Environment report if this isn't configured.

Generally backing up and restoring between Moodles with different databases types should work except there is a technical restriction specific to restoring to MySQL (and MariaDB): MDL-9391. I've seen this problem with quizzes where PostgreSQL allowed answers with units with different cases which couldn't be restored to MySQL as its UNIQUE constraint treats e.g. "cm" and "CM" as identical.

Walter: I'd suggest enabling debugging (Debug messages: DEVELOPER, Display debug messages: Yes) on the site you're restoring to, which should show more information when the database error occurs.

Average of ratings: Useful (1)
In reply to Walter Byrd

Re: Can I backup a course from Mysql and restore to Postgres?

by Colin Fraser -
Picture of Documentation writers Picture of Testers
Sorry, was in a hurry and just coming from a conversation on a similar topic, so misread the question. Dave has responded to what you asked. Thank's Dave....
In reply to Colin Fraser

Re: Can I backup a course from Mysql and restore to Postgres?

by Visvanath Ratnaweera -
Picture of Particularly helpful Moodlers Picture of Translators
There is Site administration > Development > Experimental > Database migration (in rel 3.9 at least):
Never tried though. Any experience?