Last active
May 24, 2017 06:21
-
-
Save arjunKumbakkara/5a82520334006894f5d83eb8dd2bc6f0 to your computer and use it in GitHub Desktop.
Automated DATABASE BackUp script [Use as a Cron job]
This file contains 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 | |
#---------------------------------------------------- | |
# a simple mysql database backup script. | |
# version 0.1, updated April 28, 2017. | |
# copyright 2017 Arjun Kumbakkara | |
#---------------------------------------------------- | |
#Author:Arjun Kumbakkara | |
#Organization : 6D Telecom Solutions. | |
# (1) These variables define the backing Up process | |
FILE=mconnectMediationIrancelDaily.sql.`date +"%Y%m%d"` | |
DBSERVER="" | |
DATABASE1="" | |
DATABASE1="" | |
DATABASE1="" | |
USER=uroot | |
PASS=proot | |
# (2)Previous version of the same file removal | |
unalias rm 2> /dev/null | |
rm ${FILE} 2> /dev/null | |
rm ${FILE}.gz 2> /dev/null | |
# (3)The real Deal. | |
# use this command for a database server on a separate host:[in any case that finds a needy context!Yikes] | |
#mysqldump --opt --protocol=TCP --user=${USER} --password=${PASS} --host=${DBSERVER} ${DATABASE} > ${FILE} | |
#this gives something like this: mysqldump -uroot -proot --databases SOME_BOOT SOME_DEMO_FOR_IRAN SUMTION > db_backup.sql | |
# use this command for a database server on localhost. add other options if need be. | |
mysqldump -${USER} -${PASS} --databases ${DATABASE1} ${DATABASE2} ${DATABASE3} > ${FILE} | |
echo "Automated Dump of SOME_BOOT,SUMTION,SOME_DEMO_FOR_IRAN Processed." | |
#/home/scmuser/****/CronAutomatedDumps | |
sshpass -p 'passkey' scp ${FILE} user@10.0.0.18:/home/user/ArjunKumbakkara/CronAutomatedDumps | |
#scp ${FILE} scmuser@10.0.0.0:/home/****/ArjunKumbakkara/CronAutomatedDumps | |
#mv ${FILE} -h10.0.0.0 | |
# (4) gzip the mysql database dump file | |
gzip $FILE | |
# (5) The file Creation is notified thus | |
echo "${FILE}.gz was created:" | |
ls -l ${FILE}.gz |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment