#!/bin/sh DESTINATION=/home/cybr/pds-backups SOURCE=/home/cybr/pds BACKUP=${DESTINATION}/pds_$(date +"%m-%d-%Y").tar.gz cd ${DESTINATION} ls -tr | head -n -5 | xargs rm if [ -e $BACKUP ]; then echo "The backup for pds_${timestamp} has failed." | tee ${DESTINATION}/Error_$(date +"%m-%d-%Y") else tar -vczf ${BACKUP} ${SOURCE} fi