Jump to content

Recommended Posts

Posted

Hi

 

I am having problems getting a cron job set to backup out moodle server running ubuntu to a windows share..

 

Could anybody point me in the right direction?

 

Thanks

Posted (edited)

I've just so happened to set up backups last week. Heres my scrips etc;

 

You'll need smbclient and smbfs(?iirc) installed.

 

winfp1 = the windows box which holds the backups.

data dir = /moodledata/data

backup dir (which is on the moodle box) = /moodledata/backups

 

fstab entry to map smb share = //winfp1/Linux_Backups$/moodle /winfp1 smbfs auto,credentials=/root/.winfp1_credentials,workgroup=DOMAIN 0 0

/root/.winfp1_credentials =

username=user

password=pass

 

crontab

 1 0 * * * perl /var/www/moodle/mysqldumper/msd_cron/crondump.pl -config=mysqldumper -html_output=0
 5 0 * * * /root/scripts/compress
 0 6 * * 0 /root/scripts/weekly
 0 8 * * * /root/scripts/dailypurge

 

Ive used an app called mysqldumper, heres the script it outputs to backup the BD

perl /var/www/moodle/mysqldumper/msd_cron/crondump.pl -config=mysqldumper -html_output=0

 

 

Ive used 7zip to compress the data, then it all gets copied to the daily folder

compress

7za a -t7z -mx9 -mmt /moodledata/backups/data/daily/moodledata_`date +%Y_%m_%d`.7z /moodledata/data/
cp /moodledata/backups/data/daily/moodledata_`date +%Y_%m_%d`.7z /winfp1/data/daily/
cp /moodledata/backups/sql/moodb_`date +%Y_%m_%d`* /winfp1/sql/

 

 

On a weekend after the backup has run it then copies that backup to the weekly folder

weekly

cp /moodledata/backups/data/daily/moodledata_`date +%Y_%m_%d`* /moodledata/backups/data/weekly/
cp /moodledata/backups/data/daily/moodledata_`date +%Y_%m_%d`* /winfp1/data/weekly/

 

This script then prunes the backups so that you keep only a weeks worth of daily backups and a years worth of weekly.

dailypurge

find /moodledata/backups/data/daily* -mtime +7 -exec rm {} \;
find /winfp1/data/daily* -mtime +7 -exec rm {} \;
find /moodledata/backups/data/weekly* -mtime +370 -exec rm {} \;
find /winfp1/data/weekly* -mtime +370 -exec rm {} \;

Edited by Guest

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now



×
×
  • Create New...