From d91ca9d5b9effa30360f1a552f175c9c26c52f6a Mon Sep 17 00:00:00 2001 From: hxcde <30338980+hxcde@users.noreply.github.com> Date: Sat, 8 Apr 2023 21:39:51 +0200 Subject: [PATCH] Create zip_folder_daily.sh --- zip_folder_daily.sh | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) create mode 100644 zip_folder_daily.sh diff --git a/zip_folder_daily.sh b/zip_folder_daily.sh new file mode 100644 index 0000000..09c63fc --- /dev/null +++ b/zip_folder_daily.sh @@ -0,0 +1,16 @@ +#!/bin/bash + +# Directory to be zipped (e.g., /path/to/folder) +SOURCE_DIR="/path/to/folder" + +# Directory where the zipped files will be stored (e.g., /path/to/archive) +ARCHIVE_DIR="/path/to/archive" + +# Create a timestamp in the format YYYY-MM-DD +DATE=$(date +%Y-%m-%d) + +# Create the zipped archive and append the date +zip -r "${ARCHIVE_DIR}/folder_${DATE}.zip" "${SOURCE_DIR}" + +# Delete files older than 14 days +find "${ARCHIVE_DIR}" -name "folder_*.zip" -mtime +13 -exec rm {} \;