Skip to content

Instantly share code, notes, and snippets.

@vikas5914 vikas5914/pre-commit
Created Jul 14, 2017

Embed
What would you like to do?
Git Pre commit DB export hook
#!/bin/bash
DBUSER=""
DBPASS=""
DB=""
SCHEMAPATH=""
DATE=$(date +"%d-%m-%Y-%H-%M-%p")
if [ ! -d "$SCHEMAPATH" ]; then
mkdir $SCHEMAPATH
fi
mysqldump -u $DBUSER --password=$DBPASS $DB > $SCHEMAPATH/$DB-$DATE.sql
git add $SCHEMAPATH/$DB-$DATE.sql
echo "Database succesfully exported to file:" $DB-$DATE.sql
exit 0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.