#!/bin/bash

THIS_FILE=${0}
SLACK_NOTIFIER="/home/thomas/dotfiles/scripts/slack_notifier.sh"
USER=thomas
export XDG_RUNTIME_DIR=/run/user/1000
source /home/thomas/.env

if mountpoint -q /media/samsung-T3; then
	SNAPSHOT=$(sudo /usr/bin/rsnapshot -c /etc/rsnapshot.conf hourly 2>&1 1>/dev/null)
	if [ $? -ne 0 ]; then
		$SLACK_NOTIFIER "backups" "ERROR Hourly /home backup failed" "$SNAPSHOT"
	else
		$SLACK_NOTIFIER "backups" "SUCCESS Hourly /home backup completed."
	fi
else
	$SLACK_NOTIFIER "backups" "ERROR Hourly /home backup failed: disk not mounted."
fi
