diff --git a/backup/backup.sh b/backup/backup.sh index 50452e9..f39eea6 100755 --- a/backup/backup.sh +++ b/backup/backup.sh @@ -16,7 +16,6 @@ if [ -z "$1" ] tar -xzf ${DATE}.tar.gz rm -rf ../api/resource cp -Rv ${DATE}/resource ../api/ - fi for i in "${col[@]}" @@ -39,5 +38,8 @@ if [ -z "$1" ] tar -zcf ${DATE}.tar.gz ${DATE} fi -rm -rf ${DATE} - +# 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])$ ]] + then + rm -rf ${DATE} +fi