Last active
August 29, 2015 14:11
-
-
Save mrded/bc5be9a4420f1fece6b4 to your computer and use it in GitHub Desktop.
mysql: Import database with truncated tables.
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 | |
# Usage: | |
# $ bash import-dump.sh http://example.co.uk/dump.sql.gz | |
start=$(date +"%s") | |
echo "-> Deleting of old tables" | |
mysql --user=root -e 'DROP DATABASE wikijob;' | |
mysql --user=root -e 'CREATE DATABASE wikijob;' | |
echo "-> Downloading and importing of new tables" | |
curl -H 'Accept-encoding:gzip' $1 | gunzip -c | grep -v 'INSERT INTO `user_relationship_locator_facebook`'| mysql --user=root wikijob | |
end=$(date +"%s") | |
diff=$(($end-$start)) | |
echo "Time spent: $(($diff / 60))m$(($diff % 60))s" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment