Backup of mail.log to AWS S3

Hello, I’ve configured logrotate to rotate /var/log/mail.log daily, and to compress the old logs. I’d like to retain all logs for at least a few weeks.

I have configured the MiaB backup using an S3 bucket. That seems to work well, as far as I can judge based on the number of recent files in the bucket.

Are the (rotated) mail logs included in these backups? Or should I implement something to export all logs to S3?

I’m not sure if “Version 56” changed anything here, but all of my logs for mail.log are tar/gz’ed in the /var/log/ dir MIAB is already doing the rotating of the logs and archiving them locally at least this is what happens on my box. I typically end up deleting old logs after its built up - if I recall I think I had a years worth of logs or more, just recently deleted them so I’m not much help as far as how long they go back but its definitely more then a few weeks.

As for backing the logs up I dont believe they are copied to the backup file. At least I dont see it with a quick search in the backup.py script. (mailinabox/backup.py at main · mail-in-a-box/mailinabox · GitHub)

Check out the “mail_log.py” script to see how the logrotate is happening via MIAB builtin script. mailinabox/mail_log.py at main · mail-in-a-box/mailinabox · GitHub

Some additions:

  • Mail-in-a-Box does not archive the log files from /var/log. However, if you want to add something yourself, you can tie this in with the backup.py script using the call to an before-backup script. (see line 257)
    Add the script as $STORAGE_HOME/backup/before-backup and chmod it executable. If it exists, the backup.py script will call it after the regular mail in a box backup has finished. There is a similar call to an after-backup script.
  • The mail_log.py script is actually not used to do log rotation. Log rotation is performed by logrotate, as configured by /etc/logrotate.d/rsyslog Logrotate should also take care of cleaning up the old logfiles.
    The `mail_log.py’ file is used to create the weekly “Mail-in-a-Box Usage Report” that you get in the mail box of the administrator user.
1 Like

Thanks for the correction @KiekerJan - I’m not much of a scripter and thought I remember reading that it was for the log rotation. Guess I got confused.

1 Like

This topic was automatically closed 40 days after the last reply. New replies are no longer allowed.