Skip to content

Instantly share code, notes, and snippets.

@rawzone
Created October 14, 2013 16:36
Show Gist options
  • Save rawzone/6978433 to your computer and use it in GitHub Desktop.
Save rawzone/6978433 to your computer and use it in GitHub Desktop.
pre-commit hook for git to dumpt mysql database and add to repo.
#!/bin/bash
DBUSER="<USERNAME>"
DBPASS="<PASSWORD>"
DB="<DATABASE>"
HOST="<DATABASE HOST>"
mysqldump -u $DBUSER -p$DBPASS $DB > db/$DB.sql
git add db/$DB.sql
exit 0
@rawzone
Copy link
Author

rawzone commented Oct 14, 2013

Add this to .git/hooks/pre-commit to enable dump of database and adding it to the git repo before a commit (snapshotting the database)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment