Last active
August 29, 2015 13:56
-
-
Save BenAtWide/8808577 to your computer and use it in GitHub Desktop.
My crappy load db from a backup script
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 | |
| # 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