"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.
From novice to tech pro — start learning today.
set -e
nowdate=$(date +"%Y-%m-%d-%H")
dayago=`(date --date='02 days ago' '+%Y-%m-%d-%H')`
mondate=$(date +"%Y-%m")
backup=/backup/data
if [ -d "$backup/$mondate" ]; then
echo "found month folder"
mv /var/log/apache2/access.lo
gzip $backup/$mondate/access.$n
else
echo "no month folder found creating $mondate"
mkdir $backup/$mondate/
cp /var/log/apache2/access.lo
gzip $backup/$mondate/access.$n
fi