As a follow up to a previous question, linked here, I have revised the code and developed what I believe to be a better solution.
In summary, the script should backup all files in a particular directory, and assign them to a particular zip file based on their modification dates. This should only occur for files modified yesterday and older, and skip files with the ".zip" extension.
Please let me know if their are any improvements that you would make? From testing the code, it has been working with no issues:
#!/bin/bash
yestdayend=$(date --date="yesterday" +"%Y-%m-%d 23:59:59")
path=/path/to/dir
filelist=$(find $path -maxdepth 1 ! \( -name "*.zip" \) -type f ! -newermt "$yestdayend")
for file in $filelist
do
moddate=$(stat -c %y $file | cut -d " " -f 1)
if zip -rv $path/"logbackup-"$moddate.zip $file; then
rm $file
fi
done