Search code examples
linuxbinaryfileslogrotate

Rotate Binary File on Linux


I've been trying to use logrotate to rotate a binary file based on size, but the program does not seem to work with binary files. For what it's worth, here's the configuration that I'm using for this specific file:

<filepath> {
  copytruncate
  compress
  missingok
  size 10M
  rotate 100
  nomail
}

Can anyone suggest a program that can handle binary files and has the same basic features as logrotate ?


Solution

  • in fact logrotate can handle binary files - I use logrotate to rotate database dumps - i.e.

    /backups/mysql/mydatabase.sql.gz {
       rotate 7
       nomissingok
       create
       nocompress
       nocopy
       prerotate
       test -x /usr/bin/mysqldump || exit 1
       test -x /bin/gzip || exit 1
       mysqldump --user=xyz --password='*****' mydatabase | gzip -q -7 > /backups/mysql/mydatabase.sql.gz
       endscript
    }
    

    read this for more information: http://www.rackspace.com/knowledge_center/article/understanding-logrotate-utility