Results 1 to 5 of 5

Thread: [SOLVED] Logrotate to external device possible?

  1. #1
    blazeking is offline Advanced Member
    Join Date
    May 2008
    Location
    California!
    Posts
    226
    Rep Power
    6

    Default [SOLVED] Logrotate to external device possible?

    I know this more of a Linux question than Zimbra, but maybe some of you have done what I'm trying to do. I'd like to keep /var/log/maillog and /var/log/zimbra.log for longer than I have storage for (1 year). I attempted to specify a NAS drive as the destination for logrotate, as that has additional space, but I get the error:

    error: /tmp/.webmin/562265_1_save_log.cgi:8 olddir /log_backup/zimbra/zmail1 and log file /var/log/maillog are on different devices

    "/log_backup" is mounted via CIFS. I want to automate this process, but I'm not a cron master. Any ideas?
    Last edited by blazeking; 07-14-2010 at 02:20 PM.

  2. #2
    phoenix is offline Zimbra Consultant & Moderator
    Join Date
    Sep 2005
    Location
    Vannes, France
    Posts
    23,201
    Rep Power
    56

    Default

    Why not set-up a syslog server?
    Regards


    Bill


    Acompli: A new adventure for Co-Founder KevinH.

  3. #3
    jrefl5 is offline Advanced Member
    Join Date
    Nov 2007
    Location
    AZ, USA
    Posts
    205
    Rep Power
    7

    Default

    or you could create a script to copy the just rotated out logfile (zimbra.log.1[.gz]) to your san storage, then add a line to the "postrotate" stanza of /etc/logrotate.d/zimbra.

    Note Remember to redo the new line(s) after each upgrade of zimbra.

    zimbralog.sh = something like
    Code:
    #!/bin/bash
    LogDate=$(date +"%Y-%m-%d)"
    cp -p /var/log/zimbra.log.1 /dest/zimbra.log.$LogDate
    exit
    /etc/logrotate.d/zimbra in the /var/log/zimbra.log code add
    Code:
    /scriptlocation/zimbralog.sh
    to the postrotate stanza, just before the "endscript" line.

    Additional scripts for each log to copy, or design 1 script to take a filename as input then add as needed to the logrotate directives.
    Last edited by jrefl5; 07-14-2010 at 02:02 PM. Reason: correct code example

  4. #4
    blazeking is offline Advanced Member
    Join Date
    May 2008
    Location
    California!
    Posts
    226
    Rep Power
    6

    Default

    phoenix - That's probably the better answer, but too much for me on this issue.

    jrefl5 - I believe you've given me what I need. I also compress zimbra.log during rotation, so I this is what I have now:

    /var/log/zimbra_log_rotate.sh:
    Code:
    #!/bin/bash
    LogDate=$(date +"%Y-%m-%d")
    cp -p /var/log/zimbra.log.1 /log_backup/zimbra/zmail1/zimbra.log.$LogDate
    gzip /log_backup/zimbra/zmail1/zimbra.log.$LogDate
    exit
    /etc/logrotate.d/zimbra:
    Code:
    /var/log/zimbra.log {
            missingok
            notifempty
            create 0644 zimbra zimbra
            postrotate
            killall -HUP syslogd 2> /dev/null || true
            su - zimbra -c "/opt/zimbra/bin/zmswatchctl restart" > /dev/null 2>&1 || true
            /var/log/zimbra_log_rotate.sh || true
            endscript
            compress
            weekly
    }
    
    ...

  5. #5
    jrefl5 is offline Advanced Member
    Join Date
    Nov 2007
    Location
    AZ, USA
    Posts
    205
    Rep Power
    7

    Default

    You could save the zcat by adding a delaycompress to the /etc/logrotate.d/zimbra;
    Code:
    /var/log/zimbra.log {
            missingok
            notifempty
            create 0644 zimbra zimbra
            postrotate
            killall -HUP syslogd 2> /dev/null || true
            su - zimbra -c "/opt/zimbra/bin/zmswatchctl restart" > /dev/null 2>&1 || true
            /var/log/zimbra_log_rotate.sh || true
            endscript
            compress
            delaycompress
            weekly
    }
    but then again we rotate daily, not weekly, so smaller files to begin with.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. external imap-account does not work proper
    By gruad23 in forum Installation
    Replies: 0
    Last Post: 02-19-2010, 03:16 AM
  2. Replies: 1
    Last Post: 12-22-2008, 09:47 PM
  3. Replies: 1
    Last Post: 11-01-2008, 11:52 PM
  4. External Users given the short end...
    By Mace in forum Users
    Replies: 0
    Last Post: 10-31-2008, 09:29 PM
  5. [SOLVED] Error running mailboxd after script backup
    By ttortosa in forum Administrators
    Replies: 5
    Last Post: 10-22-2008, 01:33 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •