#!/bin/bash
TIME=`date +"%F"` # time stamp to the backup file
TIME_SIX_AGO=`date --date="6 days" +%F`
FILENAME="backup_$TIME.tar.gz" # defining the format of the file name while backing up
SRCDIR="/home/bungeecord" # Location of the backup directory
DESDIR="/home/backupSerenia" # Destination of the backup directory (where you need to backup)
tar -cpzf $DESDIR/$FILENAME $SRCDIR # Executing the command
if [ -f /home/backupSerenia/backup_`$TIME_SIX_AGO`.tar.gz]
then
rm /home/backupSerenia/backup_`$TIME_SIX_AGO`.tar.gz
fi