I've this script that creates a mysql dump of a database and sends it to a storage server. But I see that, sometimes, the generated files is of wrong size, even sending the file with rsync.

I'd like to test the remote file for md5sum and if hash is the same, the local file is removed. If the hash is different, though, the rsync is re-attempted. 

The original script is:

```
#!/bin/bash

# database credentials

DATABASEHOST=<host>
DATABASEUSER=<user>
DATABASEPASSWORD=<password>
DATABASESCHEMA=<schema>
DATABASEENV=<env>

# Local directory of mysqldump file
LOCALDIR=<localdir>

# Temporary directory for compressed file
TEMPDIR=<tempdir>

# Remote Directory for backups.
REMOTEDIR=<remote-dir>

# USERname to login as
BACKUPUSER=<backupuser>

# Backup host to login to
BACKUPHOST=<backuphost>

# mysqldump file
MYSQLDUMPFILE="$(date +%Y%m%d)"_bkp_"$DATABASESCHEMA".sql

# compressed file
COMPRESSEDFILE="$(date +%Y%m%d)"_"$DATABASEENV"_"$DATABASESCHEMA".tar.gz

#--- end config

echo $(date +%H:%M)
echo "Creating the MySQL dump" 
mysqldump --host="$DATABASEHOST" --user="$DATABASEUSER" --password="$DATABASEPASSWORD" --single-transaction "$DATABASESCHEMA" > "$LOCALDIR"/"$MYSQLDUMPFILE"

#echo "Generating md5sum"
md5sum "$LOCALDIR"/* > "$LOCALDIR"/checklist.chk

#echo "Compressing the dump and checklist"
tar -cvzf "$TEMPDIR"/$(date +%Y%m%d)"_"$DATABASEENV"_"$DATABASESCHEMA".tar.gz" "$LOCALDIR"/*

#echo "Sending the compressed file to storage location"
rsync -azvh "$TEMPDIR"/"$COMPRESSEDFILE" "$BACKUPHOST":"$REMOTEDIR"

echo "Removing generated files"
rm "$LOCALDIR"/checklist.chk > /dev/null 2>&1

rm "$LOCALDIR"/"$MYSQLDUMPFILE" > /dev/null 2>&1

rm "$TEMPDIR"/"$COMPRESSEDFILE" > /dev/null 2>&1

echo $(date +%H:%M)

```