Advertisement
Guest User

Untitled

a guest
Apr 16th, 2017
82
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.00 KB | None | 0 0
  1. #!/bin/sh
  2. # init. the projects informations
  3. PROJECT=PROJECT_NAME
  4. FILE=$PROJECT.`jdate +%Y-%m-%d`.sql
  5. DBSERVER=DATABASE_SERVER
  6. DATABASE=DBNAME
  7. USER=DBUSER
  8. PASS=dbpassword
  9.  
  10. #in case you run this more than once a day, remove the previous version of the file
  11. unalias rm 2> /dev/null
  12. rm ${FILE} 2> /dev/null
  13. rm ${FILE}.gz 2> /dev/null
  14.  
  15. #do the mysql database backup (dump)
  16.  
  17. # use this command for a database server on a separate host:
  18. #mysqldump --opt --protocol=TCP --user=${USER} --password=${PASS} --host=${DBSERVER} ${DATABASE} > ${FILE}
  19.  
  20. # use this command for a database server on localhost. add other options if need be.
  21. mysqldump --opt --user=${USER} --password=${PASS} ${DATABASE} > ${FILE}
  22.  
  23. #gzip the mysql database dump file
  24. gzip $FILE
  25.  
  26. #show the user the result then move it to a destination then push it to it's git repo
  27. echo "${FILE}.gz was created:"
  28. ls -l ${FILE}.gz
  29. mv ${FILE}.gz /root/backup/${PROJECT}/${DATABASE}/
  30. 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