Note: You are currently viewing documentation for Moodle 2.9. Up-to-date documentation for the latest stable version of Moodle may be available here: Site Backup for Low-tech Users.

Site Backup for Low-tech Users: Difference between revisions

From MoodleDocs
(backup template)
 
(15 intermediate revisions by 3 users not shown)
Line 1: Line 1:
==Site Backup for Low-Tech Users==
{{Backup}}
{{Review}}
This page is written for Moodle site administrators who are interested in learning about site backup and restore process, but who are not familiar with code, command lines or website administration.  For others please see [[Site backup]].


This page is submitted for review and correction.  
A complete Moodle site backup involves 3 things: the Moodle code, the moodledata folder and the MySQL tables.  A course backup and download off site is always a best practice but it only involves parts of the moodledata folder and SQL table.  


If you use Moodle and administer your site, and you do not write Unix/Linux command lines or php code, you can still understand how to back up your site.
:TIP: Please remember there are many different configurations for webservers and Moodle sites. Most of the instructions below should start with the words "Generally speaking".  




1. First, it’s a good idea to reread the two Moodle FAQs about Beginning Administration: [https://docs.moodle.org/en/Beginning_Administration_FAQ]
==Before disaster strikes==
and [https://docs.moodle.org/en/Beginning_Administration_2_FAQ]
"''Do not gamble what you can not afford to lose''": think carefully about how often you will backup things and where.  


Also, revisit '''cPanel''', which is a common webhost interface, where you manage what you have on your hosted server space.  
When a major Website disaster happens, you may need to restore the three parts:
*moodledata folder - sometimes called the: data files, Moodle files, data directory, uploaddata, dataroot, or simply moodledata (in lowercase). It is not called the "database".
*[[MySQL]] or [[PostgreSQL]] database -  We will refer to the MySQL database.  There are other SQL database flavors which will work with Moodle.
*[[Moodle site moodle directory|Moodle code]] - location of Moodle code.


You probably used cPanel when you installed Moodle. It includes '''File Manager'''. In addition, cPanel includes '''phpMyAdmin'''. This utility will be used to back up and, if necessary, query your database. PhpMyAdmin is documented in language that presumes computer expertise. But you can browse the Web for videos (on, for example YouTube) of how people with Moodle use phpMyAdmin.  For example, there are Moodle videos using cPanel at http://www.e-blackboard.org/.
Thus it is a good idea to first know how to backup these parts so you can restore them to a new or existing webserver.


== Backing Up to Upgrade Moodle ==
== Course Backups - better than nothing ==
As the site administrator, you probably have set an automatic course backup in your site settings.  Sometimes site administrators forget that these backups should be copied to a safe place other than their webserver.  Teachers maybe encouraged to download their course(s) backups to their computer on a weekly basis. 


2. Backing up in order to upgrade Moodle can raise the specter of databases whose default “collation” or “character set” is not exclusively the utf-8 that Moodle requires.  You can see a discussion of this issue, relevant to those who used Fantastico to install Moodle, here http://moodle.org/mod/forum/discuss.php?d=140949
The course backups and restores only deal with parts of the moodledata folder and MySQL tablesFor example, they may include reference to a default theme or a contributed code module, but not the actual code or information that will make them work.


== Course Backups First ==
== Backup up key folders==
You will need a program and rights to go into your website files to make a backup.  You can copy the folder to another off site location, or zip the folders and copy that zip file to another location. 


3. Every Moodler should download the free book ''Using Moodle'' 2nd edition in .pdf. https://docs.moodle.org/en/Using_Moodle_book
An FTP (file transfer protocol) program might be useful. There are free programs such as  CyberDuck and FileZillaA FTP program copies a file from "there" (the server) to “here” (your desktop)Usually this is as simple as a drag and drop and then waiting for the files to transfer.
It tells you all about how to create Moodle coursesIts final chapter (16) describes basic system administration, including how to automate the backing up of your coursesThat automated course backup is really simple and you should do it.  
 
Some webhosts will have an interface that will allow you to create a zip or tar file and download it from the server to your desktop, similar to a FTP program.


If a course is ever broken, fouled, or lost, there is a “restore” feature built right into Moodle’s front-page administration block.  It restores courses from backups.  In order to practice restoring a course, be sure to include among your Moodle courses a shell or “dummy” course.
===Back up your moodledata folder===


The rest of ''Using Moodle’s'' final chapter explains the administration settings on Moodle’s front page. All those explanations are vitalHowever, ''Using Moodle'' cannot tell you how to backup your whole site.
Use your program to copy (that is, drag and drop) the directory called “[[moodledata]]” or the zip or tar file you created that contains this folder. This folder was named and  created in the install processIt usually located in a public directory, not in the same directory as the moodle code folder.


== Besides your courses, what should you back up? ==
===Backup the moodle code folder===
Use your program to copy (that is, drag and drop) the directory that contains the moodle code.  This directory is usually called "moodle" and maybe in the public root (htdocs). You may have created a tar or zip file of this directory and it's contents.


4.     To understand a site backup, you should know that Moodle software is supported by three other software programs.  (These will be installed on your webhost’s server, and your host maintains and updates them.) In most cases, these three are the open-source (free) software programs called Apache (server software), MySQL (which creates and stores your databases), and PHP (the language that allows Apache and MySQL to communicate).  You can have alternatives to these particular three “brand names,” but you will always need all three types—plus the Moodle code itself.
:Tip: Some sites only use the standard install package.   And some of the site administrators of these sites like to use a clean install of their Moodle code, instead of using a backup as described above. A potential problem with this practice may involve sites that have added modules or tweaked the standard Moodle, because these things will not be in a standard install.


It’s good to read the Site Backup FAQ [https://docs.moodle.org/en/Backup_FAQ] You will not understand everything, but that’s OK.
==Backup the MySQL database==
Backing up the MySQL database is a different process and uses a different type of program.  Here is [http://www.youtube.com/watch?v=ifPJzlqq1rQ a video of the process.]


Experienced system administrators back up their sites according to instructions here:
MySQL can be thought of as a series of databases.  Each database is made up of tables that share a common prefix in their name. Each table has records. The Moodle intaller creates the Moodle tables prefix.  A typical prefix is "mdl_". The goal is to backup these tables.
[https://docs.moodle.org/en/Site_backup]  But that page assumes that readers can write Unix/Linux commands and php code. If you cannot, the steps below should help you.  


===Open phpMyAdmin===
[[phpMyAdmin]] can be installed as part of the Moodle interface.  When [[MySQL Admin|installed]] it can be found in the site administration block>Server>database.  Many webhosts will use a program called cPanel, or have a link to program that can manage the MySQL database such as phpMyAdmin.  We will use phpMyAdmin.


5.     If a disaster happens, you will need to restore, from zipped backup copies, two of the three components of your Moodle systemThese two are
Open phpMyAdmin. In the left pane, you will see your database(s) listed.  Normally, the name of a Moodle database will be something like mdl_ or have the description Moodle.  Click on the database you want to back up.   


'''your moodledata folder and your MySQL database(s).'''  
The page will refresh.  In the left column you should see all (around 200) the tables with the prefix of mdl_ (or what ever they were named when the Moodle site was installed).  Along along the top you will now see a row of buttons. Click on the button Export.   


(The third component is the folder where you installed your Moodle code. I will discuss that component later.)
You will see boxes with options in them (see below).
 
One difficulty is that these three components are called by confusingly similar names.


::a. '''The data folder.'''  This is also called data files, Moodle files, data directory, or moodledata (uploaddata if Fantastico installed your site).  Sometimes this folder is also called dataroot because that’s where it’s located.
[[Image:PhpMyAdminExport.jpg|thumb|center|Enlarge to see an example of phpMyAdmin screen shot]]


::b. '''Your database''', or data tables, usually in a MySQL database.  Strictly speaking, these are not files; they are tables.  Taking this backup is often called a MySQL dump, a database dump, or a database export.
*Check “Select all. ” In the Structure box
*Click “Add DROP TABLE, etc.”
*When in doubt, leave a setting at it's default
*Go down to the bottom and find “Save as file”
it is a good idea to today’s date to the default name.  
*Select the compression method (here we selected gzipped)
*Press Go in the lower right corner


::c. '''Moodle code''': that is, the version of Moodle you’re using. If you don’t back this file up, you can instead download a recent “weekly” version of Moodle and reenter any tweaks you have addedThis Moodle code, if you care, is stored on your server at a location called dirrootSo sometimes it’s called the Moodle directory.
A popup window will ask you whether you want to save the exported file.  Click OK (Save)Wait for the process to finish.


== The Steps to a Low-Tech Site Backup ==
phpMyAdmin will zip a copy of your database and send it to your home computer’s desktop.


6. Get an '''ftp''' (file transfer protocol) program.  I bought a really simple one (Transit) for about $25, but there are free ftp programs such as CyberDuck and FileZilla.  This ftp program copies a file from “them” (the server) to “us” (your desktop) when you drag and drop. 


7. Back up your data folder:  Use your ftp program to copy (that is, drag and drop) the file called “moodledata” or (in a Fantastico install) “uploaddata.”  It will be zipped as a file that ends in .tar.gz  You don’t need to unzip it, but keep it where you can find it.
==Tips and tricks==


8. Back up your database:  Here’s a video that shows how: [http://www.youtube.com/watch?v=ifPJzlqq1rQ]
===Useful and free books===
Every Moodler should download the free book ''Using Moodle'' 2nd edition in .pdf. https://docs.moodle.org/en/Using_Moodle_book
It tells you all about how to create Moodle courses.  Its final chapter (16) describes basic system administration, including how to automate the backing up of your courses.  That automated course backup is really simple and you should do it.


In words, here’s how: Go to your server’s cPanel. Open adminMyPhpIn the left pane, you will see your database(s) listed.  Normally, a Moodle database will include an underline and mdle; and mine has 198 tables in it.  Click on the database you want to back up.
The rest of ''Using Moodle’s'' final chapter explains the administration settings on Moodle’s front page. All those explanations are vitalHowever, ''Using Moodle'' does not tell you how to backup your whole site.


The page will refresh and along the top you will now see a row of buttons. Click on the button Export. 
===Beginning administration FAQs===


You will see boxes with options in them (see below).
It is a good idea to reread the two Moodle FAQs: [https://docs.moodle.org/en/Beginning_Administration_FAQ Beginning_Administration_FAQ]
and [https://docs.moodle.org/en/Beginning_Administration_2_FAQ Beginning_Administration_2_FAQ]
 
===cPanel===
'''cPanel'''is a common webhost interface, where you manage what you have on your hosted server space.  


[[Image:PhpMyAdminExport.jpg]]
You probably used cPanel when you installed Moodle. It includes '''File Manager'''. In addition, cPanel includes '''phpMyAdmin''' that we discussed above.


Check “Select all. ” In the Structure box, I leave the defaults, and also click “Add DROP TABLE, etc.
=== Another Site Backup ===
It is a good practice for a site administrator to have a test site not on their production server. If you have a spare computer capable of Internet connection, you can create a backup/test Moodle site.  This is a great way to develop your abilities and test the process without using your production site.  See one of the [[Complete install packages]].


Go down to the bottom and find “Save as file”: add today’s date to the default name.  After “Compression,” I select gzippedThen, down in the lower right, press GOA popup window will ask you whether you want to save the exported file.  Click OK (Save).  Wait a minute or two.
:TIP: Create two different webservers as localhosts with the complete install packages.  Turn on one and set it up as your production serverTurn it off and turn on the other webserver as perform the restore process on itHopefully you will not need to do this on your real production server, but you can practice.


AdminMyPhp will zip a copy of your database and send it to your home computer’s desktop.


Remember, I said that the third component's backup was less urgent?


I am told that you can use an ftp program to backup your Moodle code—the folder where your Moodle is stored. I have not done so yet. I can always download a fresh Moodle from the Web at Moodle downloads http://moodle.org/downloads/
=== What else should you back up? ===
There are a few webserver files that might be handy to have.  


== Another Site Backup ==
Moodle software is supported by three other types of software packages: a webserver ([[Apache]]), the [[PHP]] code processor  and a database([[MySQL]]) server.  These will be installed on the webserver.  A webhost will generally maintain and updates these and other packages.  These programs work with Moodle code and communicate with each other.


Finally, if you have a spare computer capable of Internet connection, you can create a backup/test Moodle site.
It’s good to read the Site Backup FAQ [https://docs.moodle.org/en/Backup_FAQ]  You will not understand everything, but that’s OK.
 
Experienced system administrators back up their sites according to instructions here:
[https://docs.moodle.org/en/Site_backup]  But that page assumes that readers can write Unix/Linux commands and php code.  We have give you a simplier alternative above.


Temporarily connect that computer to the Internet. Download the Moodle package or "appliance" appropriate for your operating system, such as MAMP [https://docs.moodle.org/en/Complete_Install_Packages_for_Mac_OS_X]
=== Backing Up before an upgrade or adding a new module ===
or another one of the packages described here: [https://docs.moodle.org/en/Administrator_documentation#Mac]


Create as many empty courses as you have on your site. Then increase the upload limit: on your front page, under Administration>Security>Site policies, find Maximum upload size and increase it to whatever you need for your largest ''course'' backup.  
Backing up prior to upgrading Moodle, needs special attention to details.  Remember, when you upgrade Moodle, it will change the Moodle code, and probably the MySQL tables and perhaps things in the moodledata folder.  This is also true if you are tweaking the code or adding contributed code.  The old parts may not be compatible the new.


Then go into each empty course, and use Administration>Import to import your ''course'' backup. Don't forget to import your glossaries and front page.  
If for some reason the install does not work, you will probably want to roll things back by restoring the backups you made of MySQL, the Moodle code and moodledata.  


Now you have a test Moodle. It’s not secure; so don’t open it up to the Web. But you will have a complete, working copy of your site.
You can see a forum discussion of this issue, reguarding Fantastico to install Moodle, [http://moodle.org/mod/forum/discuss.php?d=140949 here].


{{stub}}
==See also==
Could someone explain, step by step, for those who have not written php code or command-line Unix/Linux, how to restore from site backups?  Perhaps a video like the installation video at at http://ic.eflclasses.org/tutorials/ ?
*[[Site backup]] General process for backing up a site
*[[Site restore]]
*[[Tools for backing up server files]] for experienced administrators

Latest revision as of 10:49, 13 October 2011

This page is written for Moodle site administrators who are interested in learning about site backup and restore process, but who are not familiar with code, command lines or website administration. For others please see Site backup.

A complete Moodle site backup involves 3 things: the Moodle code, the moodledata folder and the MySQL tables. A course backup and download off site is always a best practice but it only involves parts of the moodledata folder and SQL table.

TIP: Please remember there are many different configurations for webservers and Moodle sites. Most of the instructions below should start with the words "Generally speaking".


Before disaster strikes

"Do not gamble what you can not afford to lose": think carefully about how often you will backup things and where.

When a major Website disaster happens, you may need to restore the three parts:

  • moodledata folder - sometimes called the: data files, Moodle files, data directory, uploaddata, dataroot, or simply moodledata (in lowercase). It is not called the "database".
  • MySQL or PostgreSQL database - We will refer to the MySQL database. There are other SQL database flavors which will work with Moodle.
  • Moodle code - location of Moodle code.

Thus it is a good idea to first know how to backup these parts so you can restore them to a new or existing webserver.

Course Backups - better than nothing

As the site administrator, you probably have set an automatic course backup in your site settings. Sometimes site administrators forget that these backups should be copied to a safe place other than their webserver. Teachers maybe encouraged to download their course(s) backups to their computer on a weekly basis.

The course backups and restores only deal with parts of the moodledata folder and MySQL tables. For example, they may include reference to a default theme or a contributed code module, but not the actual code or information that will make them work.

Backup up key folders

You will need a program and rights to go into your website files to make a backup. You can copy the folder to another off site location, or zip the folders and copy that zip file to another location.

An FTP (file transfer protocol) program might be useful. There are free programs such as CyberDuck and FileZilla. A FTP program copies a file from "there" (the server) to “here” (your desktop). Usually this is as simple as a drag and drop and then waiting for the files to transfer.

Some webhosts will have an interface that will allow you to create a zip or tar file and download it from the server to your desktop, similar to a FTP program.

Back up your moodledata folder

Use your program to copy (that is, drag and drop) the directory called “moodledata” or the zip or tar file you created that contains this folder. This folder was named and created in the install process. It usually located in a public directory, not in the same directory as the moodle code folder.

Backup the moodle code folder

Use your program to copy (that is, drag and drop) the directory that contains the moodle code. This directory is usually called "moodle" and maybe in the public root (htdocs). You may have created a tar or zip file of this directory and it's contents.

Tip: Some sites only use the standard install package. And some of the site administrators of these sites like to use a clean install of their Moodle code, instead of using a backup as described above. A potential problem with this practice may involve sites that have added modules or tweaked the standard Moodle, because these things will not be in a standard install.

Backup the MySQL database

Backing up the MySQL database is a different process and uses a different type of program. Here is a video of the process.

MySQL can be thought of as a series of databases. Each database is made up of tables that share a common prefix in their name. Each table has records. The Moodle intaller creates the Moodle tables prefix. A typical prefix is "mdl_". The goal is to backup these tables.

Open phpMyAdmin

phpMyAdmin can be installed as part of the Moodle interface. When installed it can be found in the site administration block>Server>database. Many webhosts will use a program called cPanel, or have a link to program that can manage the MySQL database such as phpMyAdmin. We will use phpMyAdmin.

Open phpMyAdmin. In the left pane, you will see your database(s) listed. Normally, the name of a Moodle database will be something like mdl_ or have the description Moodle. Click on the database you want to back up.

The page will refresh. In the left column you should see all (around 200) the tables with the prefix of mdl_ (or what ever they were named when the Moodle site was installed). Along along the top you will now see a row of buttons. Click on the button Export.

You will see boxes with options in them (see below).

Enlarge to see an example of phpMyAdmin screen shot
  • Check “Select all. ” In the Structure box
  • Click “Add DROP TABLE, etc.”
  • When in doubt, leave a setting at it's default
  • Go down to the bottom and find “Save as file”

it is a good idea to today’s date to the default name.

  • Select the compression method (here we selected gzipped)
  • Press Go in the lower right corner

A popup window will ask you whether you want to save the exported file. Click OK (Save). Wait for the process to finish.

phpMyAdmin will zip a copy of your database and send it to your home computer’s desktop.


Tips and tricks

Useful and free books

Every Moodler should download the free book Using Moodle 2nd edition in .pdf. https://docs.moodle.org/en/Using_Moodle_book It tells you all about how to create Moodle courses. Its final chapter (16) describes basic system administration, including how to automate the backing up of your courses. That automated course backup is really simple and you should do it.

The rest of Using Moodle’s final chapter explains the administration settings on Moodle’s front page. All those explanations are vital. However, Using Moodle does not tell you how to backup your whole site.

Beginning administration FAQs

It is a good idea to reread the two Moodle FAQs: Beginning_Administration_FAQ and Beginning_Administration_2_FAQ

cPanel

cPanelis a common webhost interface, where you manage what you have on your hosted server space.

You probably used cPanel when you installed Moodle. It includes File Manager. In addition, cPanel includes phpMyAdmin that we discussed above.

Another Site Backup

It is a good practice for a site administrator to have a test site not on their production server. If you have a spare computer capable of Internet connection, you can create a backup/test Moodle site. This is a great way to develop your abilities and test the process without using your production site. See one of the Complete install packages.

TIP: Create two different webservers as localhosts with the complete install packages. Turn on one and set it up as your production server. Turn it off and turn on the other webserver as perform the restore process on it. Hopefully you will not need to do this on your real production server, but you can practice.


What else should you back up?

There are a few webserver files that might be handy to have.

Moodle software is supported by three other types of software packages: a webserver (Apache), the PHP code processor and a database(MySQL) server. These will be installed on the webserver. A webhost will generally maintain and updates these and other packages. These programs work with Moodle code and communicate with each other.

It’s good to read the Site Backup FAQ [1] You will not understand everything, but that’s OK.

Experienced system administrators back up their sites according to instructions here: [2] But that page assumes that readers can write Unix/Linux commands and php code. We have give you a simplier alternative above.

Backing Up before an upgrade or adding a new module

Backing up prior to upgrading Moodle, needs special attention to details. Remember, when you upgrade Moodle, it will change the Moodle code, and probably the MySQL tables and perhaps things in the moodledata folder. This is also true if you are tweaking the code or adding contributed code. The old parts may not be compatible the new.

If for some reason the install does not work, you will probably want to roll things back by restoring the backups you made of MySQL, the Moodle code and moodledata.

You can see a forum discussion of this issue, reguarding Fantastico to install Moodle, here.

See also