Installing and upgrading help

Backup/Restore full Moodle Site (from 2.1.3 to latest Moodle version)

 
Picture of Andy Carrein
Backup/Restore full Moodle Site (from 2.1.3 to latest Moodle version)
 

Good day everyone,

Our university has merged with another university that used Moodle. We are finishing the teach-outs and were thinking about extracting the SQL from the hosted Moodle site and dump the file on a local server, running the latest Moodle version. We would like to keep all the data and be able to access previous courses to review grades, syllabi, etc.


We have tried to do this, but PhpMyAdmin on the local server said that the file was too big (62Gb) to process, so we changed the settings to allow bigger files than what we are trying to put in the database. This still did not work. We have then tried to use a tool that would stagger the SQL import, but that also failed.

Anyone here with experience in doing just that? Am I missing something? I have read the Moodle instructions and have Googled several options.

 
Average of ratings: -
Picture of Ken Task
Re: Backup/Restore full Moodle Site (from 2.1.3 to latest Moodle version)
Particularly helpful Moodlers

Others ... especially those that actually wear the hat of DB admin and are true certified types ... might have better/different info ... but ...

Query the current DB to find the largest tables. Using a command line client one could run a mysqldump with an option to ignore those tables. 

For archival purposes one probably doesn't need the mdl_log_store which is a log of all actions nor the stats tables etc.

For query for largest tables:

https://www.percona.com/blog/2008/02/04/finding-out-largest-tables-on-mysql-server/

For mysqldump command to exclude those tables:

https://dev.mysql.com/doc/refman/5.7/en/mysqldump.html#option_mysqldump_ignore-table

Check the size then of the .sql file you have to import into your other server.

You might have to re-construct those tables after importing the database so that your copy doesn't complain and throw errors.

And it probably wouldn't hurt to share some info about the specs of your DB server - like memory?  DB server dedicated or on same server as the web/moodle code?

'spirit of sharing', Ken


 
Average of ratings: -
Picture of Rick Jerz
Re: Backup/Restore full Moodle Site (from 2.1.3 to latest Moodle version)
Particularly helpful Moodlers

phpMyAdmin gets a little weird when files get very big.

You will be better off using ssh.  Here's how I do it (make the necessary changes.)  You will notice that I backup the moodle application, MySQL database, and the moodledata folder. 

NOW=$(date +%F)

# Backup up the current files

echo Backup the Moodle database

mysqldump -uyourdbuser -pyourpassword --opt -r/home/yourhome/backup_moodle/$NOW-moodledb.sql anyname_moodle3

echo Backup config.php

cp /home/rjerzcom/public_html/moodle/config.php /home/yourhome/backup_moodle/$NOW-config.php

echo Backup moodle

tar cfz backup_moodle/$NOW-moodle.gz public_html/moodle

echo Backup moodledata

tar cfz backup_moodle/$NOW-moodledata.gz moodledata3/

 
Average of ratings: -
Picture of AL Rachels
Re: Backup/Restore full Moodle Site (from 2.1.3 to latest Moodle version)
Core developersParticularly helpful MoodlersPlugin developersTesters

Hi Andy,

In the past I had problems with PhpMyAdmin when trying to move a database. Once I started using the built  in export and import capability of MySQL, I have never had a failure. Here are the steps I started using back in Moodle 2.2 days.

Export

To Export a database, open up terminal, making sure that you are not logged into MySQL and type,

cd /root
mysqldump -u [username] -p [database name] > [database name].sql
What I used:
mysqldump -u root -p moodle22 > moodle22.sql

The database that you selected in the command will now be exported to your root users folder. Move it to your root user folder of the new server.

Import

To import a database, first create a new blank database in the MySQL shell to serve as a destination for your data. Instead of the following, in phpMyAdmin create a new user, database and password using the info in config.php.

CREATE DATABASE newdatabase;

Then log out of the MySQL shell and type the following on the command line:

mysql -u [username] -p newdatabase < [database name].sql
What I used:
mysql -p -u root moodle22 < moodle22.sql
If the dump is large, the import can take a while, so be patient.
 
Average of ratings: Useful (1)
Picture of Ken Task
Re: Backup/Restore full Moodle Site (from 2.1.3 to latest Moodle version)
Particularly helpful Moodlers

Some food for thought?

I support a corp site that is allowing another corp to 'share' their moodle.   Great!  Saves cost etc. but, every once in a while Corp B (the one 'mooching') wants to do something the hoster Corp does not.   So that's a rub.   If Corp B allowed to make site backups, they have all of Corp A's users and courses.

In your case, is the other Edu 'good' with you having a complete copy of the shared site?   When you do get it installed, you'll have all other other Edu's courses, users, etc.   If not removed, there is a chance for errant email or notifications being sent to users of the other edu.  Confusion!

Option: if not too many courses ... on the shared server, make full backups of your Edu's courses.   If using Linux the server op could script a command line script that could do that.   You then, would, of course, have to restore all those backups to your server.   But, all data in your server is your Edu's.

'spirit of sharing', Ken


 
Average of ratings: Useful (1)