From 0d17d59791b25d3a4eb1859590b096a58a6e0e1e Mon Sep 17 00:00:00 2001 From: Daniel Dolezal <40464775+daniel156161@users.noreply.github.com> Date: Sat, 22 Aug 2020 02:31:43 +0200 Subject: [PATCH] Update pfsense-backup.sh --- pfsense-backup.sh | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/pfsense-backup.sh b/pfsense-backup.sh index 95e720a..f527110 100755 --- a/pfsense-backup.sh +++ b/pfsense-backup.sh @@ -64,13 +64,16 @@ if [ $cron -eq 1 ]; then echo "$PFSENSE_CRON_SCHEDULE FROM_CRON=1 /pfsense-backup.sh" | crontab - crond -f else - do_backup - if [ ! -z $keepfiles ]; then - remove=$(ls -d -1tr $destination/*.xml | tail -n +$keepfiles | head -n1) - if [ ! -z $remove ]; then - rm -f $(ls -d -1tr $destination/*.xml | tail -n -$keepfiles | head -n1) - fi + do_backup + if [ ! -z $keepfiles ]; then + remove=$(ls -d -1tr $destination/*.xml | tail -n +$keepfiles | head -n1) + if [ ! -z $remove ]; then + keepfiles=$((keepfiles + 1)) + del=$(ls $destination/*.xml | tail -n -$keepfiles | head -n1) + rm -f $del + echo "Backup removed at $del" fi + fi fi else do_backup