Git Pre-Commit MySQL Dump / Backup


/ Published in: Bash
Save to your folder(s)



Copy this code and paste it in your HTML
  1. #!/bin/sh
  2. # Refresh the SQL schema file for inclusion within the git commit
  3.  
  4. # If something fails, exit with status other than 0
  5. set -e
  6.  
  7. # first, remove our original schema
  8. cd /var/www
  9. rm -f filename.sql
  10.  
  11. # generate a new schema
  12. mysqldump -u username --password=password database > filename.sql
  13.  
  14. # Add the schema to the next commit
  15. git add filename.sql
  16.  
  17. # Exit success
  18. exit 0

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.