Note: You are currently viewing documentation for Moodle 1.9. Up-to-date documentation for the latest stable version is available here: Site backup.
Creating a backup of a Moodle site
Site backup is going to be the primary page for backup instruction. Before we deleted and relink things to this page, we need to refocus.
- There's also Backup and restore FAQ which might also need some overhaul or even merging with this page. --Frank Ralf 11:51, 21 November 2010 (UTC)
- Good point. I will look at FAQ as a dummy and see if it is helpful and has lots of links. --chris collman 14:39, 21 November 2010 (UTC)
The "Creating a backup.." section is confusing to me. I think it needs a major rewrite. IMO I would like to continue clear separation in our language and documentation about the 3 parts to backup: sql, moodledata, moodle code. I will change the name of the "Data files" section.
I want to move the whole bit on the rsync tool to its own page for techies who want to and can use it. rsync is not the only tool of it's kind and if I am not mistaken is a Linux OS flavor tool and this subsection under "data" has commands which are dealing with sql.
My apologies in advance to people who know what they are talking about and for my ranting, but the language in this section is casual for non techies and ESL folks as a primary page :) --chris collman 16:12, 20 November 2010 (UTC)--chris collman 15:30, 20 November 2010 (UTC)
- Hi Chris, I would also suggest moving the restore instructions to a separate page. --Frank Ralf 11:47, 21 November 2010 (UTC)
- Hi Frank, thanks for edits and additions. I also had the same thought about "restore" but decided I would run down the backup stuff first and be link happy. --chris collman 14:39, 21 November 2010 (UTC)
- Did not know that redirect existed. Do you think we should change that REDIRECT to a disambiguation page, with a links/notes where to go for a site and a course restore? Similar to Backup. I have not done a check links on all the pages we have worked on :) Good catch. --chris collman 18:42, 22 November 2010 (UTC)
Text in Motion
While it appears that Helen moved much of the prior content of the Backup FAQ page to the Backup Doc, she did not move the comments (i.e. the material below)..... the result being that the comments on the material now found here appeared without the comments..... I have copied the comments over and look forward to further comment and discussion before changing others work....
Marc Grober 13:13, 3 October 2008 (CDT)
I have some concerns about some of the material provided in this FAQ. I am concerned that the command line resources are potentially being provided to new users who will get very very confused. I also think that the FAQ should, if anything, really be an index into the docs.
As far as specifics:
There are two main things you need to make a copy of - the database and the uploaded files. The Moodle scripts themselves are less important, since you can always download a fresh copy if you have to.
Aside from ending in "to", ;) , I have to challenge the accuracy of this statement in that I demonstrated that it can be next to impossible to download the save version of moodle as you had installed and it is just so very simple to back this up as well.
Here is an outline of a little script you can run on Unix to backup the database
This is not a script but a list of commands that one might consider in developing a script.
cd /my/backup/directory mv moodle-database.sql.gz moodle-database-old.sql.gz mysqldump -h example.com -u myusername --password=mypassword -C -Q -e --create-options mydatabasename > moodle-database.sql gzip moodle-database.sql
While it is obvious one can't move something that does not exist, I just know that someone is going to complain about this.
Because so many people get confused over -p[password] I do concur that longopts should be recommended, but I think it would also be helpful if the suggestions used longopts throughout, as in
mysqldump --user=[username] --password=[password] --opt [dbname]>[outputfile]
Of course, the error that usually results from placing a space between -p and a password regarding being unable to locate table "nameofthedatabasetobedumped" should be included.
Because the lines may break, it is important with longer lines either to force the break and add the \ and provide a placeholder for the system prompt.
2. If you are running mysql, a backup of the database should be a .sql, .gz or .tar.gz file. If it is .tar.gz or .gz you need to extract it until it is an sql file.
Arguably whether you are running mysql or not has nothing to do with whaty you used to back up your sql file or its extensions. Backed up files may also be in tgz format and could be zip'd or rar'd for that matter.
For the files, you can use rsync regularly to copy only the changed files to another host:
While the rsync info is great, it assume knowledge of how to set up rsync and provides no references of any sort. On the other hand, there is no discussion of simply tarring/gziping the files.
Since phpmyadmin is so prevalent it might be help to include information on using this tool, as well as information on dropping tables in an existing database.
And files don't try to do anything..... Perhaps as noted above a discussion of how to drop tables before importing the sql file might be helpful
But, as suggested, I think this should all be covered in the full docs in appropriate sections, with the FAQ simply pointing to the various doc sections.
--Marc Grober 14:59, 9 July 2008 (CDT)
While adding or deleting /1/maintenance.html as a means of putting Moodle in or out of maintenance mode may have its promoters and detractors, creating or deleting that file should be a feature of all backup and restore scripts.
One aspect of backup that should be addressed is replication. There are bugs reported as far as using mysql replication with Moodle, and more importantly, mysql replication could cause havoc if it is used to create a duplicate site and db replication is not timed to take place when moodle is in maintenenace mode and moodledata also updated to match change in db. On the other hand, if one is using say a round robin on a replicated mysql Moodle db (pointing at the same moodledate) is this effective and bombproof?
Marc Grober 13:13, 3 October 2008 (CDT)
- Marc, thanks for your comments. As suggested, content has been moved from Backup and restore FAQ to other pages. Most likely there is more which can be moved. Please feel free to edit the section on creating a backup of your Moodle site in Site backup according to your comments. Any help is much appreciated, as I'm definitely not a backup expert ;-) --Helen Foster 08:49, 3 October 2008 (CDT)
- Using Moodle An error occurred deleting old backup data forum discussion
- Using Moodle Meaning of error message forum discussion
A big THANK YOU to Eloy Lafuente (stronk7) :-) Helen Foster 26 November 2005 17:34 (WST)
Why were the examples using rsync removed from the article. I thought they were very useful.