Skip to content

Instantly share code, notes, and snippets.

@dbmurphy
Last active August 29, 2015 14:11
Show Gist options
  • Save dbmurphy/788123194d223478f5b5 to your computer and use it in GitHub Desktop.
Save dbmurphy/788123194d223478f5b5 to your computer and use it in GitHub Desktop.
ClouldFiles Uploading of a backup....
CloudFilesUser="XXXX"
CloudFilesKey="XXXXXX"
mongoshost="XXXXXX"
mongosport=99999
mongouser="XXXXXX"
mongopass="XXXXX"
#Path to you mongo binaries
mongobinpath=~/mongodb-linux-x86_64-2.4.6/bin
db=$(echo `date +"stats_%d%m%Y"`)
echo "We are processing the ${db} database at `date`"
dump_start=`date`
$mongobinpath/mongodump -h ${mongoshost} --port ${mongosport} --authenticationDatabase ${db} -u ${mongouser} -p ${mongopass} -d ${db} -o ${db}
if [ ! -d ${db} ];then
dump_exit=1
else
dump_exit=0
fi
dump_stop=`date`
echo "Dump ran between ${dump_start} and ${dump_stop} and have exit code of ${dump_exit} (0 is good!)"
if [ "${dump_exit}" -ne 0 ];then
echo "Aborted due to dump error!"
exit 1
fi
tar_start=`date`
tar zcf ${db}.tgz ${db}
tar_exit=`echo $?`
tar_stop=`date`
echo "Tar ran between ${tar_start} and ${tar_stop} and had exit of ${tar_exit} ( 0 is good)"
if [ "${tar_exit}" -ne 0 ];then
echo "Aborted due to tar error!"
exit 1
fi
echo "Starting Upload using ST (SwiftTool)"
upload_start=`date`
./st -A https://lon.auth.api.rackspacecloud.com/v1.0 -U $CloudFilesUser -K $CloudFilesKey upload -S 1073741824 report_backups_or ${db}.tgz
upload_exit=`echo $?`
upload_stop=`date`
echo "Upload ran from ${upload_start} to ${upload_stop} with exit of ${upload_exit} (0 is good)"
if [ "${upload_exit}" -ne 0 ];then
echo "Aborted due to tar error!"
exit 1
fi
echo "Files found on CF for today..."
./st -A https://lon.auth.api.rackspacecloud.com/v1.0 -U $CloudFilesUser -K $CloudFilesKey list report_backups_or | grep ${db}
echo "File Segements on CF for today..."
./st -A https://lon.auth.api.rackspacecloud.com/v1.0 -U $CloudFilesUser -K $CloudFilesKey list report_backups_or_segments | grep ${db}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment