Created
November 22, 2012 17:55
-
-
Save mariusbutuc/4132374 to your computer and use it in GitHub Desktop.
BDU: Take online backup of MOODLE2 and store it in S3 script.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
########################################################### | |
# | |
# Take online backup of MOODLE2 and store it in S3 script. | |
# | |
########################################################### | |
echo '\n\n################# New MOODLE2 backup ################################################################' >> moodle2_backup.log | |
export DATABASE=MOODLE2 | |
export TZ='America/Toronto' # set Toronto's timezone, for timestamping logs | |
echo "$(date) \t | #1: Taking online backup" >> moodle2_backup.log | |
db2_backup_output=`su - db2inst1 -c "db2 backup database $DATABASE online TO /mnt/backups/ include logs"` | |
echo $db2_backup_output >> moodle2_backup.log | |
echo "\n$(date) \t | #2: Test the integrity of the backup image" >> moodle2_backup.log | |
backup_file_full_path=`ls -t1 /mnt/backups/$DATABASE* | head -n1` # full path of the latest backup file | |
db2ckbkp_output=`su - db2inst1 -c "db2ckbkp $backup_file_full_path" | grep -i 'error\|success'` # case insen. grep for success/error | |
echo $db2ckbkp_output >> moodle2_backup.log | |
echo "\n$(date) \t | #3: Store backup image (S3)" >> moodle2_backup.log | |
backup_file_name_only=`ls -t1 /mnt/backups/$DATABASE* | head -n1 | cut -d/ -f4` | |
s3_put_output=`s3cmd put $backup_file_full_path s3://bigdatauniversity/$DATABASE/$backup_file_name_only` | |
echo $s3_put_output >> moodle2_backup.log | |
echo "\n$(date) \t | #4: TODO: Was the backup stored successfully (S3)?" >> moodle2_backup.log | |
#TODO: Optionally, using Rightscale, you can check the backup was uploaded to the S3 bigdatauniversity bucket successfully. | |
echo "\n$(date) \t | #4: Backup finished" >> moodle2_backup.log | |
echo "Backup finished" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment