Created
July 14, 2017 10:47
-
-
Save vikas5914/06666accac9f8b7c588e9a05e8d388cf to your computer and use it in GitHub Desktop.
Git Pre commit DB export hook
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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