Zimbra offers Open Source email server software and shared calendar for Linux and the Mac
Go Back   Zimbra :: Forums > Zimbra Collaboration Suite > Administrators

Welcome to the Zimbra :: Forums!
Welcome, if you would like to post a comment please register. We also encourage you to explore all things Zimbra with our team and members of the community.

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 07-14-2010, 12:36 PM
Advanced Member
 
Posts: 204
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..
Reply With Quote
  #2 (permalink)  
Old 07-14-2010, 12:53 PM
Zimbra Consultant & Moderator
 
Posts: 20,313
Default

Why not set-up a syslog server?
__________________
Regards


Bill
Reply With Quote
  #3 (permalink)  
Old 07-14-2010, 02:01 PM
Advanced Member
 
Posts: 205
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
Reply With Quote
  #4 (permalink)  
Old 07-14-2010, 03:15 PM
Advanced Member
 
Posts: 204
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
}

...
Reply With Quote
  #5 (permalink)  
Old 07-15-2010, 06:14 AM
Advanced Member
 
Posts: 205
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.
Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes


Similar Threads

Why Join?

Registering let's you ask questions, makes it easier to search, displays any files attached to posts, and notifies you about replies.

blog.zimbra.com




 

SEO by vBSEO ©2011, Crawlability, Inc.