From 32b8d78047e328dd9cd1e3b5b52a10cd972c2fa4 Mon Sep 17 00:00:00 2001 From: Thomas Lange Date: Fri, 15 Nov 2019 08:42:28 +0100 Subject: mkdir DIRECTORY_ROOT if not exist --- Bash/virtualhosts-backup.sh | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) (limited to 'Bash/virtualhosts-backup.sh') diff --git a/Bash/virtualhosts-backup.sh b/Bash/virtualhosts-backup.sh index ecdcb3b..eb2a9b7 100755 --- a/Bash/virtualhosts-backup.sh +++ b/Bash/virtualhosts-backup.sh @@ -47,7 +47,11 @@ DIRECTORY_FROM="/var/www/" #=============================================================================== # Delete old backups in backup root directory #=============================================================================== -find "${DIRECTORY_ROOT}"* -maxdepth 0 -type d -mtime +14 -exec rm --recursive {} \; +if [ -d "${DIRECTORY_ROOT}" ]; then + find "${DIRECTORY_ROOT}"* -maxdepth 0 -type d -mtime +90 -exec rm --recursive {} \; +else + mkdir -p "${DIRECTORY_ROOT}" +fi #=============================================================================== # Create backup path directory if not exists @@ -84,4 +88,4 @@ for username in $(find ${DIRECTORY_FROM}* -maxdepth 0 -type d -exec basename {} [ ! $ARGUMENT_QUIETMODE ] && echo "[INFO] Creating compressed backup for virtualhost $virtualhost [...]" tar --create --bzip2 --file "$(printf "${DIRECTORY_FILE}" "${virtualhost}")" --directory "${DIRECTORY_FROM}${username}/" "${virtualhost}" done -done \ No newline at end of file +done -- cgit v1.2.3