In the faq from the moodle documentation, there is the following description:
How do I backup my whole Moodle site?
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.
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 moodle-database.sql.gz moodle-database-old.sql.gz
mysqldump -h example.com -u myusername --password=mypassword -C -Q -e -a mydatabasename > moodle-database.sql
gzip moodle-database.sql
For the files, you can use rsync regularly to copy only the changed files to another host:
rsync -auvtz --delete -e ssh mysshusername@example.com:/my/server/directory /my/backup/directory/
Kind regards, Ian