#!/bin/bashSRCDIR=$1DSTDIR=$2CURRENTDATE=$(date +%s)#CHECK FOR THE LAST UPDATE LOGif [[ -s lastupdate.log ]]; then LASTUPDATE=$(<lastupdate.log)else >lastupdate.log LASTUPDATE=${CURRENTDATE}fiecho "Creating a backup of ${SRCDIR} in ${DSTDIR}"if [[ -z "${SRCDIR}" ]]; then echo "You must specify a source directory" exit 1fiif [[ -z "${DSTDIR}" ]]; then echo "You must specify a destination directory" exit 1fiDSTDIR="${DSTDIR}/${CURRENTDATE}"mkdir -p "${DSTDIR}"find "${SRCDIR}" -maxdepth 1 -type f -newer lastupdate.log -exec cp {} "${DSTDIR}/ \; -exec echo {} was updated, creating a copy \;find "${SRCDIR}" -maxdepth 1 \( -newer lastupdate.log \) -prune -o -type f -exec ln {} "${DSTDIR}/ \; -exec echo {} was not updated, creating a hard link \;#Store the new date in the logecho "${CURRENTDATE}" > lastupdate.log