Defined by: logrotate

2 entries shown.

How do I back up the logs that have been rotated by an older version of logrotate? (posted by scruff)
Say that your version of logrotate doesn't support the dateext directive ...

/etc/logrotate.d/apache
-----------------------
(remove the dateext directive)

/scripts/oldlogs.sh
-------------------
#!/bin/bash

BASEDIR="/backup/oldlogs"
TODAYDIR="${BASEDIR}/$(date +%F)"

if ! [ -x $TODAYDIR ]
then
echo "Creating $TODAYDIR ..."
mkdir -p $TODAYDIR
echo "Copying current log snapshot to $TODAYDIR ..."
for i in $(find /home/domlogs -type 'f' -name "*.1.gz" -mtime -1)
do
cp $i $TODAYDIR
done
# The following two lines can be uncommented to change the compression
# scheme for the oldlogs from gzip to bzip2.
#gunzip $TODAYDIR/*
#bzip2 $TODAYDIR/*
else
echo "Old logs have already been backed up for today's date."
fi
How do I back up the logs that have been rotated? (posted by scruff)
Well, here's how I did it for apache domlogs ...

/etc/logrotate.d/apache
-----------------------
/usr/local/apache/domlogs/*.com /usr/local/apache/domlogs/*.org /usr/local/apache/domlogs/*.ftp_log /usr/local/apache/domlogs/*.com-ssl_log /usr/local/apache/domlogs/*.us /usr/local/apache/domlogs/*.info /usr/local/apache/domlogs/*.net
{
daily
compress
notifempty
missingok
rotate 31
dateext
sharedscripts
postrotate
/scripts/oldlogs.sh
/bin/kill -HUP `cat /usr/local/apache/logs/httpd.pid 2>/dev/null` 2>/dev/null || true
endscript
}

/scripts/oldlogs.sh
-------------------
BASEDIR="/backup/oldlogs"
TODAYDIR="${BASEDIR}/$(date +%F)"
TODAY=$(date +%Y%m%d)

if ! [ -x $TODAYDIR ]
then
echo "Creating $TODAYDIR ..."
mkdir -p $TODAYDIR
echo "Copying current log snapshot to $TODAYDIR ..."
cp -a /home/domlogs/*${TODAY}* $TODAYDIR
else
echo "Old logs have already been backed up for today's date."
fi