Skip to content

Instantly share code, notes, and snippets.

@jsocol
Created June 8, 2010 17:11
Show Gist options
  • Star 3 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jsocol/430320 to your computer and use it in GitHub Desktop.
Save jsocol/430320 to your computer and use it in GitHub Desktop.
pvimport - load a gzipped sql dump through pv
#!/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
@rlr
Copy link

rlr commented Jun 8, 2010

woot

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment