You're looking at an older version of Totara Learn.

Please see Totara 14 help for the latest version.

On this page


A site backup allows a Site Administrator to save everything associated with a Totara site. These backups can be restored to bring a site back to the point in time when the backup was made.

Performing regular backups is highly recommended to reduce the amount of lost information in the event of a problem on the site and to speed the overall recovery process.

What to back up

A Totara system comprises three parts:

  1. The data stored in the database e.g. a MySQL database
  2. The uploaded files e.g. site and course files uploaded via Totara located in moodledata
  3. The Totara code e.g. everything in /server/htdocs/totara

You can confirm where all these things are located in a Totara installation by checking the config.php file.

$CFG->dbname shows the database name$CFG->prefix shows the the database table name prefix$CFG->dataroot controls where the uploaded files are stored; and$CFG->wwwroot points to where the code is stored.

Generally speaking, the database ("dbname and prefix") and the uploaded files (dataroot) are the two most important to copy on a regular basis. These contain information that will change most often.

The Totara code (wwwroot) is less important as a frequent backup, since it will only change when the the actual code is changed through upgrades, addins, and code tweaks. You can always get a copy of the standard Totara from Totara so you only have to backup the parts you added or changed yourself.

Creating a backup of your Totara site


The right way to back up your database depends on which database system you are using. The instructions below are one way to back up a MySQL database. Another option would be to use a tool like phpMyAdmin to manually make a backup. The documentation for your database will give more options.

There are many ways to do such backups. Here is an outline of a little script you can run on Unix to backup the database (it works well to have such a script run daily via a cron task):

cd /my/backup/directory
mv Totara-database.sql.gz Totara-database-old.sql.gz
mysqldump -h -u myusername --password=mypassword -C -Q -e --create-options mydatabasename > Totara-database.sql
gzip Totara-database.sql 

Character encoding

Make sure that a database backup uses the correct character encoding. In most databases, use UTF-8.

When dumping the entire Totara database, check for possible character encoding issues. In some instances, backups created with mysqldump or phpMyAdmin may not properly encode all of the data. This will result in non-readable characters when the database is restored.

One solution is to use MySQL Administrator 1.1 or another tool that will force a UTF-8 dump of the data.

Tools for database backups

phpMyAdminphpMyAdmin is the tool of choice with most web hosting providers.

MySQLDumperMySQLDumper is a backup script for MySQL databases, written in PHP and Perl. MySQLDumper uses a proprietary technique to avoid execution interruption when running PHP scripts (the max. execution time is usually set to 30 seconds). MySQLDumper also cares for the encoding problems mentioned above. It also works with compressed files and allows setting up regular cron jobs for updating and updating to a remote FTP site.

Uploaded files

Through the Totara interface, users can upload or create files and folders. These are located in a directory, often called 'moodledata'. Since they are just files and folders, there are many different ways to backup or copy moodledata.

  • For example, using a file transfer program, copy the entire directory to a different area, drive or computer. Examples of file transfer programs include: FTP, WinSP, wget, rsync.
  • You might use a compression program to create compact files (tar, zip. 7z, XZ, BZIP2, GZIP, and WIM are a few file formats) of the entire directory. This can be done before or after file transfers.

Typically not all files change between regular/periodic backups. A new  Site Administrator might want to look into incremental or other efficient backups procedures.

Depending upon the operating environment there are many tools for backing up server files and ways of backing up moodledata. 

Totara code

Backing up the Totara code, will be similar to backing up moodledata. 

It is always a good idea to have several backup copies of your Totara code files. While you can always download a fresh base copy of the Totara code from Totara you might have customised that code. It is a good idea to create a separate backup of your Totara code before you customise the code. This includes installing contributed code, themes, and upgrading.

Provide feedback about this page using the link in the bottom right of this page. 

 Still have questions? 

Why not post them in the forums on the Totara Community?

  • No labels