So the Moodle install is up and running. Time for a simple database backup using the Mysqlhotcopy tool. It allows for literally "hot" copying of the database without stopping the service!
This can be shell scripted to run nightly.
0. Login as root.
1. Make a script directory and create a bare shell script
mkdir /temp/scripts && cd /temp/scripts
chmod +x database_backup.run
2. Edit the script using VI or nano (I <3 nano)
Add lines (edit to include your database name, username, password etc). Since the database password will be stored in the file as plaintext, make sure the folder is owned by root. If preferred, the date can be appeded to the end of the foldername for simple identification.
mysqlhotcopy -u yourdbusername -p yourdbpassword --addtodest yourdbname /path/to/backup/folder
mv /path/to/backup/folder /path/to/backup/folder_$(date +%Y%m%d)_(date +%H%M)
Save and exit
3. Test the script to make sure it works as advertised!
Once it runs without errors, it can be set to run automatically via cron.
4. Add the script to the crontab to execute nightly
I prefer to run this script at periods of low activity - 1:00am should be fine for most installs.
Append the following:
#database backup script
00 1 * * * root /bin.sh /temp/scripts/database_backup.run
This tutorial demonstrates how to make a copy of raw database files on the same server that the database resides on.
Later on (when I get some time), I will show how to extend the strategy to