Linux – Logrotate: Rotating non-log files

linuxlog-fileslogrotate

I have a backup script that compresses various files and directories and creates .tgz archives. Files are named, e.g.

...
backup_2010-10-28.tar.gz
backup_2010-10-29.tar.gz
backup_2010-10-30.tar.gz
backup_2010-10-31.tar.gz
backup_2010-11-01.tar.gz

I want to manage these files so only the last 5 backups are kept, with older files being deleted.

Can I use logrotate to do this? They aren't log files and are already compressed. They're in /root and not in /var/log – can I still use it?

Thanks

Best Answer

Logrotate rotates files, so the answer is yes - probably, and if no sufficient permissions then place them in /backup or something. Check what group and user the rotated logs have :-).

There's options for compression in logrotate, så if "compress" is NOT configured - well then it won't try. Also in your case, "rotate 5" option.

Take a look in /etc/logrotate.d (or where ever it's stored in your system)