Skip to content

Instantly share code, notes, and snippets.

@BenAtWide
Last active August 29, 2015 13:56
Show Gist options
  • Select an option

  • Save BenAtWide/8808577 to your computer and use it in GitHub Desktop.

Select an option

Save BenAtWide/8808577 to your computer and use it in GitHub Desktop.
My crappy load db from a backup script
#!/bin/bash
# Load a db from files in a directory
# test for minimum of command args
if [ ! -n "$1" -o ! -n "$2" -o ! -n "$3" ]
then
echo "Usage: `basename $0` dbname user password"
exit -1
fi
echo "Unzipping data..."
bunzip2 *.bz2
echo "Loading data..."
for f in `ls *.sql`;do
mysql -u $2 --password=$3 $1 < $f; done
# zip up files again.
bzip2 *.sql
echo "Data loaded."
exit 0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment