Skip to content

Instantly share code, notes, and snippets.

@iangreenleaf
Created August 18, 2010 19:35
Show Gist options
  • Save iangreenleaf/535897 to your computer and use it in GitHub Desktop.
Save iangreenleaf/535897 to your computer and use it in GitHub Desktop.
MySQL import with file names and progress bar
# Usage: reload-db /path/to/sqldump dbname
function reload-db {
for f in "$1"/*.sql; do
printf "%-${COLUMNS}s" "$f">&2;
cat "$f";
done \
| pv -s `du -sb "$1" | awk '{print $1}'` \
| mysql -uroot "$2";
if [ $? != 0 ]; then echo 'ERRORS!!!!!!!!!!!!!'; return $?; fi
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment