folder2archive/zip_folder_daily.sh

17 lines
480 B
Bash
Raw Normal View History

2023-04-08 21:39:51 +02:00
#!/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}"
2023-04-12 01:32:40 +02:00
# Delete files older than 14 days
2023-04-08 21:39:51 +02:00
find "${ARCHIVE_DIR}" -name "folder_*.zip" -mtime +13 -exec rm {} \;