Last active
March 20, 2018 09:44
-
-
Save BinaryKitten/c61c8507982ca78991903f79879ebc11 to your computer and use it in GitHub Desktop.
This file contains hidden or 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 | |
DATE=`date +%Y-%m-%d_%H-%M-%S` | |
cd "/vagrant/backups/" | |
mkdir $DATE && cd $_ | |
for i in `mysql -u root -psecret -e "show databases;" | grep -Ev "^(Database|mysql|performance_schema|information_schema)$"`; do | |
echo "dumping ${i}" | |
sudo mysqldump -c -u root -psecret ${i} > ${i}.sql | |
done |
This file contains hidden or 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 | |
for f in *.sql | |
do | |
filename=$(basename "$f") | |
extension="${filename##*.}" | |
table="${filename%.*}" | |
echo Restoring $filename to $table | |
mysql --login-path=local $table < $f | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment