Created
June 8, 2010 17:11
-
-
Save jsocol/430320 to your computer and use it in GitHub Desktop.
pvimport - load a gzipped sql dump through pv
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/sh | |
# Import a (g|b)zipped SQL dump into a specified database through pipeviewer. | |
if [ $# -lt 2 ]; then | |
echo "USAGE: $0 <filename> <database>" | |
exit 1 | |
fi | |
EXT=${1/*./} | |
if [ "$EXT" == "gz" ]; then | |
pv -cN source < $1 | gunzip | pv -cN gunzip | mysql $2 | |
elif [ "$EXT" == "bz2" ]; then | |
pv -cN source < $1 | bunzip2 | pv -cN bunzip2 | mysql $2 | |
else | |
echo "File must be .sql.bz2 or .sql.gz" | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
woot