Created
May 3, 2015 10:31
-
-
Save crazyrohila/821a64a9db37c9d25d65 to your computer and use it in GitHub Desktop.
Rackspace-Cloud-DB-Backup-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/bash | |
# Variables | |
# Replace values with Rackspace credentials. | |
rack_space_host=XXX.rackspaceclouddb.com | |
rack_space_user=abc | |
rack_space_pass=efg | |
rack_space_db=DB_Name | |
# Pick current time. | |
curdate=`date "+%m-%d-%H-%M"`; | |
# Create folder | |
db_dir='prod_backup-'$curdate; | |
mkdir $db_dir; | |
# Dump mysql DB | |
cd $db_dir && mysqldump -u$rack_space_user -h $rack_space_host -p$rack_space_pass $rack_space_db | bzip2 -c > prod_sql.sql.bz2; | |
#backup file | |
sqlzipfile='trx_prod_sql'.sql.bz2; | |
#log the status | |
if [ -f "$sqlzipfile" ] | |
then | |
echo $curdate': sql dump stored at '$sqlzipfile\n >> /var/www/log/backup/backup.log | |
else | |
echo $curdate': something went wrong; Please check the backup script OR take the back manually.'\n >> /var/www/log/backup/backup.log | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment