Easy backup for moodle db (serversided)

Easy backup for moodle db (serversided)

by Maik Riecken -
Number of replies: 13
Hi,

Maybe this litte sctipt attached to my post could be helpful for backing up the moodle-db if you are not too familar with MySQL or if you just want to have it simple.

moodle_dumper.php is a simple rewrite of phpmydump. It comes with build-in customizesations for moodle. You don't have to change anything...

Usage:
  • upload moodle_dumper.php to your moodle-directory
  • call http://your-moodle-url/moodle_dumper.php by browser to get your moodle.sql-file
  • delete moodle_dumper.php instantly after use
That's all. Should be not too difficult...

have fun...

Maik

PS:
The script will fail with very big datases due to execution time limits set by your provider.
Average of ratings: -
In reply to Maik Riecken

Re: Easy backup for moodle db (serversided)

by Erik Ringmar -
Hi Maik,

A great little programme!  Thanks a lot!  People like you are just what newbies like me need!

cheers,

Erik
In reply to Erik Ringmar

Re: Easy backup for moodle db (serversided)

by Russell Myers -
Here is another discussion on backing up the mysql databases, but a program that can be used to frequently backup the database.

http://moodle.org/mod/forum/discuss.php?d=30904

Rusty
In reply to Russell Myers

Re: Easy backup for moodle db (serversided)

by Jan Dierckx -

... and another discussion about a php script which emails the administrator a zipped copy of the database. That way the script doesn't need to be deleted everytime after it has been used.

In reply to Jan Dierckx

Re: Easy backup for moodle db (serversided)

by Timothy Takemoto -
Thank you Jan

You beat me to it. Thank you for recommending dbsender.

As I just posted, when I click the link manuallly i am sent the whole database but the database sent triggered by the cron is only one byte in size (e.g. the file attached). Any idea what I am doing wrong?

Timothy
In reply to Timothy Takemoto

Re: Easy backup for moodle db (serversided)

by Timothy Takemoto -

I forgot to attach the one byte databas dump.
When I said "You beat me to it" I was referring to the thread here where I mentioned your earlier recommendation of dbsender.
http://moodle.org/mod/forum/discuss.php?d=30904

Hmm... it seems that I can not attach the dumped file to a moodle forum post. Here it is on my server. I have been being sent these for about a year but it was only a few months ago that I realised that they were empty!
http://ds21.cc.yamaguchi-u.ac.jp/~eigo/mooeigo4-101005-1200am_sql.tar.gz

Fortunately nothing has gone seriously wrong in the meantime.

And the manual version (password protected) at
http://ds21.cc.yamaguchi-u.ac.jp/~eigo/dbb/dbb.php
works perfectly.

The one called by the cron is a seperate install on the server above /public_html

Tim

In reply to Timothy Takemoto

Re: Easy backup for moodle db (serversided)

by Jan Dierckx -

Tim,

Up to now I have never had to use the database dump to restore our school's site. Your mention of the timeout problem slightly worries me. I will try and do some experimenting dumping the database in a test installation.

Don't know what causes the one byte database dump. I have not included the dbsender script in my cronjob. Instead I have a daily task scheduled on my home pc which downloads the files from the moodledata directory that have been changed in the last 24 hours. After that it attempts to 'download' the dbsender script, thus causing the script to run. I guess for the server this would be equal to visiting the admin/dbsender.php page with a browser, just like you did when you manually entered the address of the script.

In reply to Jan Dierckx

Re: Easy backup for moodle db (serversided)

by Timothy Takemoto -
Thanks very much Jan.

When I first installed it I tried to use wget. I will have another go at doing that, rather than a cron.

Tim
In reply to Timothy Takemoto

Re: Easy backup for moodle db (serversided)

by Timothy Takemoto -
I installed wget but I am having problems executing it.
In reply to Timothy Takemoto

Re: Easy backup for moodle db (serversided)

by Jan Dierckx -

What kind of problems? Any error messages? You need to provide the path to wget to your windows environment. The easiest is probably to add a full path to the commandline before the wget command.

This is what I did. I made a text file called mirrormoodle.cmd Inside I put the following commands:

   E:\unxutils\usr\local\wbin\wget.exe -o log.txt -np -m ftp://user:password@www.olvrode.be/private/moodledata 
   E:\unxutils\usr\local\wbin\wget.exe www.olvrode.be/admin/dbsendit.php

The first line copies the moodledata directory to my local hard drive. The -m option (mirror) tells wget to copy only the files with changes since the last copy.

The next line visits the dbsendit.php script which emails me a zipped dump of moodle's database (hoping php doesn't time out when I'll have to one day actually use this mixed )

In reply to Maik Riecken

Re: Easy backup for moodle db (serversided)

by Erik Ringmar -
Hi again,

Backing up worked a treat, but how to restore the database again? I've moved host and installed a new version of Moodle. I go to PhPMyadmin and browse for moodle.sql but after I've uploaded it, I get a 'no SQP query' message. Why is this? I would hate to recreate the courses.

greetings from London,

Erik
In reply to Erik Ringmar

Re: Easy backup for moodle db (serversided)

by Timothy Takemoto -

Dear Erik

How about this

http://hostingsupport.com/manual/phpmyadmin.htm

I get an error 'No SQL query' when trying to execute a bookmark.
If PHP does not have read/write access to its upload_tmp_dir, it cannot access the uploaded query.

I get an error 'No SQL query' when trying to submit a query from the convenient text area.
Check the post_max_size directive from your php configuration file and try to increase it. 

By the way, I found it was very difficult to restore databases without them timing out. In the end I had to open the database as a textfile in an editor, and cut and pasted it into the box in two parts. Also I deleted the logs section of the database dump to reduce the size.

Timothy




 

In reply to Maik Riecken

Re: Easy backup for moodle db (serversided)

by jochen krause -
Hi there.
First, great script.
I'm not able to write any php-scripts by myself, i can only guess whats happening in each line.
I tried (by reading others Forum, php-tutorials, etc...) to change your script, so that it does not ask ME where to save the dump on my harddisk
I want it to save the dump to a predefined path.
(I want to call the script by a cron-task!)
Maybe it not a big Job for you (or somebody else) to change the file, with an XXXXXXXX as the patch where the dump shall be saved!
Bye,
In reply to jochen krause

Re: Easy backup for moodle db (serversided)

by Laurie Savage -
Using crontab is pretty easy. If you've got access to a linux terminal type man 8 crontab and you will see some examples. I run a scheduled mysqldump and use
"mysqldump moodle > db-`date+%F`.sql"
to create a sequence of dated file names - check the syntax of date (note the back ticks - not apostrophes).