From a83d5fe79070201b8a471ee846cc4edf24d572d8 Mon Sep 17 00:00:00 2001 From: HardiReady Date: Thu, 12 Oct 2017 08:25:44 +0200 Subject: [PATCH] Fix backup script --- backup/backup.sh | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/backup/backup.sh b/backup/backup.sh index f39eea6..0e1a764 100755 --- a/backup/backup.sh +++ b/backup/backup.sh @@ -29,17 +29,15 @@ do fi done -if [ $(ls -lt --hide=backup.sh | wc -l) -gt 6 ]; then +if [ $(ls -lt --hide=backup.sh | wc -l) -gt 14 ]; then $(rm "$(ls -t --hide=backup.sh | tail -1)") fi if [ -z "$1" ] then tar -zcf ${DATE}.tar.gz ${DATE} -fi - -# to avoid file deletion, if date to apply is entered with .tar.gz ending -if [[ $1 =~ ^[0-9]{4}-(0[1-9]|1[0-2])-(0[1-9]|[1-2][0-9]|3[0-1])$ ]] + rm -rf ${DATE} +elif [[ $1 =~ ^[0-9]{4}-(0[1-9]|1[0-2])-(0[1-9]|[1-2][0-9]|3[0-1])$ ]] then rm -rf ${DATE} fi