Created
April 16, 2017 07:45
-
-
Save numb95/dbb2fdcb0ae9d8cf6a208af9f2ac0888 to your computer and use it in GitHub Desktop.
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 | |
# init. the projects informations | |
PROJECT=PROJECT_NAME | |
FILE=$PROJECT.`jdate +%Y-%m-%d`.sql | |
DBSERVER=DATABASE_SERVER | |
DATABASE=DBNAME | |
USER=DBUSER | |
PASS=dbpassword | |
#in case you run this more than once a day, remove the previous version of the file | |
unalias rm 2> /dev/null | |
rm ${FILE} 2> /dev/null | |
rm ${FILE}.gz 2> /dev/null | |
#do the mysql database backup (dump) | |
# use this command for a database server on a separate host: | |
#mysqldump --opt --protocol=TCP --user=${USER} --password=${PASS} --host=${DBSERVER} ${DATABASE} > ${FILE} | |
# use this command for a database server on localhost. add other options if need be. | |
mysqldump --opt --user=${USER} --password=${PASS} ${DATABASE} > ${FILE} | |
#gzip the mysql database dump file | |
gzip $FILE | |
#show the user the result then move it to a destination then push it to it's git repo | |
echo "${FILE}.gz was created:" | |
ls -l ${FILE}.gz | |
mv ${FILE}.gz /root/backup/${PROJECT}/${DATABASE}/ | |
git add ${FILE}.gz && git commit -m `jdate +%Y-%m-%d` && git push -u origin master |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
@eXtrem0us i saw you comment after a year :)))
I think i was drunk when i wrote this script.
By the way thank you. i will change the script <3