Skip to content

Instantly share code, notes, and snippets.

@vikas5914
Created July 14, 2017 10:47
Show Gist options
  • Save vikas5914/06666accac9f8b7c588e9a05e8d388cf to your computer and use it in GitHub Desktop.
Save vikas5914/06666accac9f8b7c588e9a05e8d388cf to your computer and use it in GitHub Desktop.
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