Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/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
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement