#!/bin/bash

# THIS SCRIPT REQUIRES A KEY AND SSH CONFIG OF THE REMOTE HOST

SYNC_TYPE=TV

LOG_FILE=tv_cron.log
LOG_CHMOD=chmod_tv.log
LOG_DIR=/home/$USER/logs

TARGET_ON_HOST=/home/$USER/shares/disk1/tv
TARGET_ON_REMOTE=/home/invalid/files/_tv/

echo "STARTING $SYNC_TYPE FILE SYNC RAN AT: " `date '+%Y-%m-%d %H:%M:%S'` > $LOG_DIR/$LOG_FILE ;
/usr/bin/rsync -avz --no-perms --no-owner --no-group --stats --progress --exclude=$TARGET_ON_HOST -e "ssh -i /home/$USER/.ssh/id_rsa_what " whatbox:$TARGET_ON_REMOTE $TARGET_ON_HOST >> $LOG_DIR/$LOG_FILE
echo "CRON $SYNC_TYPE FILE SYNC RAN AT: " `date '+%Y-%m-%d %H:%M:%S'` >> $LOG_DIR/$LOG_FILE
/usr/bin/chmod 777 -R $TARGET_ON_HOST > $LOG_DIR/$LOG_CHMOD
echo "CRON CHMOD $SYNC_TYPE RAN AT: " `date '+%Y-%m-%d %H:%M:%S'` >> $LOG_DIR/$LOG_CHMOD