#!/bin/bash # Create the backup directory if it doesn't exist mkdir -p "${RSYNC_DEST}" # Run the rsync backup rsync -avP --delete --prune-empty-dirs --include-from="${RSYNC_MANIFEST}" \ "${RSYNC_SOURCE}/" \ --link-dest "${RSYNC_LATEST_LINK}" \ "${RSYNC_DEST_PATH}" # Update the latest hardlink rm -rf "${RSYNC_LATEST_LINK}" ln -s "${RSYNC_DEST_PATH}" "${RSYNC_LATEST_LINK}" # A hacky fix for the NFS timestamp touch "${RSYNC_DEST_PATH}"/timestamp.fix # Run retention policy cd "${RSYNC_DEST}" rm -rf `ls -t | tail -n +$(("${RSYNC_RETENTION_DAYS}"+2))`