Created
January 5, 2018 18:52
-
-
Save michabbb/0d60e56fad4c5b6531b2595924eb6030 to your computer and use it in GitHub Desktop.
Backup MySQL Schema to individual files and push changes to git
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 | |
NOW=`date +%Y%m%d%H%M%S` | |
GIT_MYSQL=/home/backup/mysql-schema | |
for T in `mysql -u root -N -B -e 'show tables from xxxxxx'`; | |
do | |
echo "Backing up $T" | |
mysqldump -d --skip-comments -u root xxxxxx $T | sed 's/ AUTO_INCREMENT=[0-9]*//g' > $GIT_MYSQL/$T.sql | |
done; | |
git add -A && git commit -m "schema from $NOW" && git push |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment