Hi there,
I am taking backup of moodle database everyday, but now I want to know how often you guys take backup of moodledata folder on server?
Hello Syed
It'd depend on your needs. So if you have a shared hosting, you could schedule a daily backup, or weekly...
Here is the script that I run every night on my VPS. This is run from CRON at 3am or so each morning. (You will need to make a few changes to this based upon your own installation, but I think that you will get the idea. Also, I intermittently move a backup to another system.)
# This is Rick Jerz's backup script for his production Moodle
# It keep 7 days of backup files.
# config.php is also in the moodle backup, but I like to be double safe for this important file.
# 1) config.php, 2) the database, 3) moodle (just to keep the current version), and 4) moodledata
#
# As one might see, I have a folder called "backup_moodle" on my server where I keep the backups.
# Things to improve:
# Add calculation for amount of time. Write this to log file.
# #################
# (When sharing, replace (your account), usernamen and password.)
# #################
# Today's Date
NOW=$(date +%F)
# x days ago
WEEKAGO=$(date --date="7 day ago" +%F)
# Delete the old (7 days) files first
rm -f /home/(your account)/backup_moodle/$WEEKAGO-config.php
rm -f /home/(your account)/backup_moodle/$WEEKAGO-moodledb.sql
rm -f /home/(your account)/backup_moodle/$WEEKAGO-moodle.gz
rm -f /home/(your account)/backup_moodle/$WEEKAGO-moodledata.gz
# Backup up the current files
echo Backup the Moodle database
mysqldump -u(your username) -p(your password) --opt -r/home/(your account)/backup_moodle/$NOW-moodledb.sql rjerzx_moodle3
echo Backup config.php
cp /home/(your account)/public_html/moodle/config.php /home/(your account)/backup_moodle/$NOW-config.php
echo Backup moodle
tar cfz backup_moodle/$NOW-moodle.gz public_html/moodle
echo Backup moodledata
tar cfz backup_moodle/$NOW-moodledata.gz moodledata3/
# Future improvements:
# Make an entry into the 'log' file
# Move/copy the backup files to a remote location
# Right now, I do this manually.
# In the future, use rsync the backups to a remote computer.
# This command doesn't work yet. It needs a little work.
# rsync -av /home/(your account)/backup_moodle rjerz1@domain.com:/home/rjerz1 --delete
# Notes for Restoring these backups.
# Forthcoming: