Skip to content

Instantly share code, notes, and snippets.

@rduarte
Created April 7, 2009 18:38
Show Gist options
  • Save rduarte/91380 to your computer and use it in GitHub Desktop.
Save rduarte/91380 to your computer and use it in GitHub Desktop.
Check MD5 integrity and import bzip2-sql files
#!/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