Created
April 7, 2009 18:38
-
-
Save rduarte/91380 to your computer and use it in GitHub Desktop.
Check MD5 integrity and import bzip2-sql files
This file contains 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 | |
db_host="localhost" | |
db_name="database" | |
db_user="root" | |
db_pass="" | |
file_path="/full/path" | |
while read LINE; do | |
HASH=`echo $LINE | awk '{print $1}'` | |
FILE=`echo $LINE | awk '{print $2}'` | |
if test "`md5sum $file_path/$FILE | awk '{print $1}'`" = $HASH; then | |
echo "Importando arquivo: $FILE ..." | |
bzip2 -d < $file_path/$FILE | mysql -h $db_host -u $db_user -D $db_name -p$db_pass -f -H | |
echo "OK" | |
else | |
echo "Erro no MD5 do arquivo: $FILE" | |
# TODO: | |
# Enviar email avisando da falha | |
fi | |
done < $file_path/MD5SUMS |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment