#!/bin/bash
#
# Usage: live_backup_db
#
source ~/.gamerc

remote_db_directory="$WORKING_DIRECTORY/DBbackup"
local_db_directory="/mnt/disks/m7livebackup/Database"

if [ ! -d "${local_db_directory}" ]; then
        mkdir -p ${local_db_directory}
fi

for db_machine in $(cat /etc/hosts | grep -i db | awk -F" " '{print $2}')
do
        cd ${local_db_directory}
	echo "======"
        echo "RSYNC Machine for Database from Live: ${db_machine}"
        echo ""
        rsync -avz -e ssh ${db_machine}:${remote_db_directory}/ .
	echo "======"
done

echo ""
echo "RSYNC Database Done!" 
