Copy Moodle back ups off site

In my previous post, I showed how to back up the Moodle database and courses backed up automatically every night to the server running Moodle. All good but what if you lose access to the server? It happens.

You need to move a copy of your backup to a different location. It needs to be automatic and daily as you never know when it may go down.

You can use rsync, sshpass and rsa keys to sync to another Linux machine. The problem is you need another Linux box which is running at backup time. I used an always running obsolete Linux netbook for this and you could also use another VPS at a different location, But there is a better way.

Dropbox gives you 2 Gb of storage. It is free and always available, So how do you automatically back up to Dropbox?

My instructions for this come from Linux Additive Tips A shell script called is used to create a crontab entry which will load your files to a dropbox account. Back up your database dump, course backups. moodledata and moodle code every night and know even if your Production server disappears completely, you can rebuild.

Just one last thing. There is really no need to keep all your backups and even a 2Gb Dropbox is going to fill up. Add this script to your database dump script to remove backups older than 3 days:

find /home/user/backup/ -type f -name '*.mbz' -mtime +3 -exec rm {} \;

Leave a Reply

Your email address will not be published. Required fields are marked *