Backup question

Backup question

by Michael Jensen -
Number of replies: 8

Hello Moodlers

Im currently setting our ESXI server with Veeam to quick recovery of both full VM and inkrementel backups- at least this is the idea.

Moodle setup:

Serv1 - Moodle
Serv2 - Database MariaDB
Serv3 - Fileserver with Redis

Im thinking of makin a full backup every night (hddspace is not an issue) I will deploy maintenance-script to make sure nothing will breake. It takes about 12min for the currently amount of GB.

But I want to make inkrementel backups as often as I can, will this be an issue if students are working? What I want to know is WHEN the database is finished before the file server and visa versa, does this break the system if we should ever use the inkrementel backup for recovery?

Average of ratings: -
In reply to Michael Jensen

Re: Backup question

by Brett Dalton -
Picture of Moodle HQ Picture of Particularly helpful Moodlers
what are you using for the backup exactly? if its a VM snapshot then the moment it is taken there shouldn't be an issue even if it takes some time to complete. worst case if the db snapshot is ahead of the file system you might miss a couple of submissions and get errors with files that wont load. If its the other way around there will be some orphaned files with no records but no errors.
Average of ratings: Useful (1)
In reply to Brett Dalton

Ang: Re: Backup question

by Michael Jensen -
@Brett
We are set up with Veeam Backup & Replication. Thx for your time an answer, so i let the DB go last.
In reply to Michael Jensen

Re: Backup question

by Ken Task -
Picture of Particularly helpful Moodlers

Code directory just once ... or until you update or upgrade code.   Moodle releases 'point' versions frequently - like 4.1.2+.  Good idea go backup just before pulling trigger on any update/upgrade to code, then update/upgrade.

DB daily - sql dumps have date time stamp in the filename.

When doing those, site should be in maintenance mode.  Once dump is done, site taken out of maintenance mode.  Could do a bash shell script called by cron that would/could do that.

Moodledata might best be handled using a progressive rsync which would make a mirror of moodledata - the only directory in moodledata that is a must is filedir.

Incremental backups have issues of their own ... must start with a base line, then daily (those might be small or large depending upon usage of the site).  To restore, one has to restore the baseline first then the increments - one at a time and in order!

Plugins for Moodle - which include 3rd party themes ... when updating those, probably should also backup code/db before and after.

Anyhoo ... my 2 cents.

'SoS', Ken


Average of ratings: Useful (1)
In reply to Ken Task

Ang: Re: Backup question

by Michael Jensen -
Hello Ken

thx for your feedback. Im still new on Veeam but it should handle inkrementels very well,
I guess im gonna need to test it with a sandbox, in the future.

For now Im gonna go with nightly full VM backups and inkrementels during the daytime. Im thinking better safe than sorry until I can figure out how it runs. Hopefully I dont need to restore inkrementel but only the full VM.

Once again thx for your time, great with feedback and other mindsets.
In reply to Michael Jensen

Re: Ang: Re: Backup question

by Rick Jerz -
Picture of Particularly helpful Moodlers Picture of Testers
You might be more advanced than I am at these things, Michael, but I thought that I would attach the script that I use to do my nightly backups. Ken will probably have a few improvements, like going into Maintenance mode first, and probably some other ideas. But this is how I do it. I think that you can make your appropriate substitutions in this script. Consider it a start. Also, pass back ideas for me if you have them.  Of course, I run this every night with a cron job.
Average of ratings: Useful (1)
In reply to Rick Jerz

Re: Ang: Re: Backup question

by Ken Task -
Picture of Particularly helpful Moodlers

@Rick ... food for thought?

a moodlevars.txt file - with root only ownerships/permissons

# you must manually create the backup directories
# you must provide paths and values.
# paths do NOT have trailing slashes.
# be sure to include the variables between the ticks
mdcode='/var/www/html/moodle39'
mdpath='/var/www/moodle39data'
mddbuser='root'
mddbpass=''
mddbname='moodle39'
msbudir='/mnt/data/backup/m39'
mcbudir='/mnt/data/backup/m39/courses'
mversion='391'

Then in scripts, first line is:
source ./moodlevars.txt

That reads in variables defined.

Then rest of script but using moodlevars.txt variables like $mdcode variable when I want to use a path to the moodle code.

Works same for cli scripts for DB queries.

Works on shared host, dedicated VPS's ... it just works!

But - (always a catch 22) - gotta define the variables correctly!

My 2 cents!

'SoS', Ken


Average of ratings: Useful (1)
In reply to Ken Task

Re: Ang: Re: Backup question

by Rick Jerz -
Picture of Particularly helpful Moodlers Picture of Testers
Thanks much, Ken.  

I have read about using a secondary file that provides more security.  I am going to try to implement what you suggest.
In reply to Michael Jensen

Re: Ang: Re: Backup question

by Ken Task -
Picture of Particularly helpful Moodlers

Food for thought?

Many years ago I used to do tech support at a State conference for K12 schools and the tech crew lead would invite a vendor to give a quick 30 minute demo of their product to the crew.   Then get feed back from the crew.

Well, one was about backups ... vendor demontrated quickly how a mistakenly deleted file could be restored easily with the product.   All successful of course ... a few of the young tech crew impressed ... we old dudes tend to look for things not mentioned.   At the bottom of the product screen was a line that flashed 'progress' .... you could see what it was doing ... very small font, but if you concentrated your focus at the beginning of that line, guess what we 'old dudes' saw?   rsync.

So the $ product did indeed work, but used open source/free software behind a graphical interface.

Another ... but this time ... more along the lines of 'surigical' - product does entire VM that would include all of moodle - code, db, moodledata and am sure one could extract from that site backup what one needs ... uhhhh, with moodle, better have the backup of the DB that the code version made ... and the code that made it.

So thinking of lower terms - if I make a local tar ball of code + mysqldump of DB and stick in it /home/backups/ right on the server ... I don't need to do the whole thing - just the moodle - an almost certain that 'surgical' restore would be quicker!

Uhhh - ya didn't mention course backups ... on a daily basis! smile

Anyhoo ... yes, a sandbox would be a good thing!

'SoS'. Ken