backing up courses versus backing up db

backing up courses versus backing up db

by N Hansen -
Number of replies: 6
I was wondering what the overall difference between backing up courses versus backing up one's Mysql database and one's course files. If one did not back up their courses through the Moodle interface, and only backed up their database and the course file folders manually, and one had a stupendous crash that destroyed the whole site, would reinstalling the Moodle files, restoring the database, and the course files make things the way they were? The reason I ask is because certain non-standard elements (like the Quiz essay question) currently are not getting backed up with courses, so I'm concerned about having a way to make sure that data isn't lost.
Average of ratings: -
In reply to N Hansen

Re: backing up courses versus backing up db

by Gustav W Delius -
Yes, Nicole, backing up the database and the course files is the right thing to do. With those two in hand you can restore your site to exactly the state it was in.

The course backup and restore functionality built into Moodle is really most suitable if you want to specifically back up and restore (or share or duplicate) individual courses.
In reply to Gustav W Delius

Re: backing up courses versus backing up db

by Mat Budzynski -
I've looked and haven't found a complete answer to the rest of this issue.  Thanks in advance for your help.

IF worst came to worst, and an admin lost an entire site due to a bad upgrade or anything else, how would the restore process happen?

Part of the answer (backing up) is on http://moodle.org/doc/?frame=upgrade.html

To backup the WHOLE SITE, simply copy the whole site directory and data directory to a different directory name.

To backup the mysql database, simply run
mysqldump moodle > moodle-backup-2002-10-26.sql


BUT I'm still looking for the second part of the answer (restoring).

Obviously, one can just copy back the renamed site and data directories.

HERE'S THE REAL QUESTION: How does one restore the moodle-backup.sql file that was created upon backup? 
  1. How would an admin restore a backup database over the current (bad) database?  This might be in the case of a bad upgrade.
  2. Is it the same process to restore to a machine with no database? This might be in the case of a machine/hardware failure.
Again, thanks for your help.
In reply to Mat Budzynski

Re: backing up courses versus backing up db

by Simon Bryan -
I believe the answer to that is also quite simple, the mysqldump program creates a text file which is basically an SQL file. With other databases I have deleted the corrupt database, recreated an empty database with same name and user permissions (which would persist anyway) and then simply execute the SQL statement in that database. Tools such as MySQLAdmin handle this very well.
In reply to Simon Bryan

Re: backing up courses versus backing up db

by Timothy Takemoto -

There is another (?) backup routine here

http://www.phpfreaks.com/script/view/11.php

recommended by Jan Dierckx on this thread. I got it to work in manual mode, but alas the dumps created by the cron every night have a byte size of one byte!

Also as mentioned here I have found that the dumped database is so large that it is difficult to restore it. Things time out. And to lengthen the time out is not so easy (for me anyway). I tried changing apache and php settings but failed. It seems that there are a lot of people that are having difficulty restoring very large backup files. I guess it can take a couple of hours so it will run foul of every timeout setting there is (apache?, mysql?, php?).

One way of doing it is by restoring the dump in parts.

There is also a program called megadump or something but I never got it working.

Timothy

In reply to Mat Budzynski

Re: backing up courses versus backing up db

by Russell Myers -
My understanding is this:

After your mysql dattabase has been dumped to file, you can use:

mysql -u root -p < mysqldumpfile

I use a script created by my friend to backup my databases. I then use another simple script to change the name to include the date, I have included the zip of all the files.

In the zip there are 3 scripts, backup.sh, backupmv.sh, mysqlqdump,sh.

Using the backup.sh script and cron I can have a backup of the database every night. This is my crontab:

0 0 * * * /bin/bash /mysqlbackup/backup.sh

When this script runs, it backs up the database into the same folder, then runs the backupmv.sh to rename it and add the date. All works well so far, however I have never tried to restore and I use Navicat to do backups as well, just in case.

Good luck

Rusty