#!/bin/bash
# Check to see if port is up
nc -z 192.168.1.110 873 1>/dev/null 2>&1; result=$?;
if [ $result -eq 0 ]; then
# If it is, then run rsync.
# passowrd-file contains the plaintext password to log into the rsync
# server. It's chmodded to 400.
rsync --compress --recursive --times --perms --links --delete \
~ \
--exclude '*.cache' \
--exclude '*Dropbox' \
--exclude 'Music' \
--exclude 'Videos' \
--exclude 'Pictures' \
--exclude 'Downloads' \
--exclude '*~' \
--password-file=/home/john/.config/rsyncpassword \
rsync://rsync@192.168.1.110/Backup
notify-send -u low -a rsync "Updated hourly backup of home directory."
else
notify-send -u low -a rsync "Could not backup home directory - cannot access rsync server."
fi