#!/usr/sh

TMPFILE=/tmp/snapshot.log.$$
SRC_DIR='/data/python'
BACKUP_DIR='/backup/'
{
	echo " Rsync from /data to /snapshop/:$(date) "
#	mount -o rw,remount /dev/sdc
	rsync -av ${SRC_DIR} ${BACKUP_DIR}
	rc=$?
#	mount -o ro,remote /dev/sdc

	if [[ $rc -eq 0 ]]; then 
		echo " Snapshot succeeded: $(date) "
		SUBJECT="Snapshot report (Succeeded)"
	else
		echo " Snapshot failed with rc=$rc: $(date) "
		SUBJECT="Snapshot report (Failed)"
	fi
} 2>&1 | tee $TMPFILE | logger -t "snapshot"
iconv -t utf8 $TMPFILE | mail -s "${SUBJECT}" report@vqiu.cn
rm -rf $TMPFILE
