#!/usr/bin/env bash readonly RSYNC_USER="${RSYNC_USER}" readonly RSYNC_SERVER="${RSYNC_SERVER}" main() { local filepath="$1" local name name="$(basename "${filepath}")" rsync --archive --verbose \ "${HOME}/timelapse/${name}" \ "${RSYNC_USER}@${RSYNC_SERVER}:/timelapse/${name}" # Delete outdated files. # This assumes the timelapse is created on an hourly basis. rm -f "$1" find "${HOME}/timelapse/" -mmin +60 -delete } main "$@"