Secure backup script from deleting by accident

pull/14/head
Florian Hartwich 2017-10-09 19:20:25 +02:00
parent 1406fe6c03
commit 4e8d6b4279
1 changed files with 5 additions and 3 deletions

View File

@ -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
# 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