1

I have a problem with logrotate. Each day I have a script that saves over 180 configs froms switchs and routers. Via tftp it puts the files into /scripts/backups/ with the text extension.

The names of the text files are not with the same pattern, it's the hostname of the machine (example : RTR-ETB-3702.text, RTR-DC-4101.text,PVL92300AM1-SW1.text, C9000-1.text, etc) The only thing that it's the same is the .text extension. So each day a logrotate adds the date at the name of the each file like this : RTR-ETB-3702_20210408.text, RTR-DC-4101_20210408.text,PVL92300AM1-SW1_20210408.text, C9000-1_20210408.text

I test it from the 1 of april. So I have 8 days of rotate until now. The problem is that it works well for the last two days but for the rest of the days it does this : Example for the first text file:

RTR-ETB-3701_20210408.text
RTR-ETB-3701_20210407.text
RTR-ETB-3701_20210406_20210408.text
RTR-ETB-3701_20210405_20210407.text
RTR-ETB-3701_20210404_20210406_20210408.text
RTR-ETB-3701_20210403_20210405_20210407.text
RTR-ETB-3701_20210402_20210404_20210406_20210408.text
RTR-ETB-3701_20210401_20210402_20210404_20210406_20210408.text

I see a pattern but I don't understand why it does that (6-8, 5-7, 4-6-8, 3-5-7, 2-4-6-8, 1-2-4-6-8). Why it works well for the last 2 days but not for all of it? This is my logrotate config (in /etc/logrotate.d/sauvegarde-reseau). It runs daily in cron.daily

/scripts/backups/*.text {
        daily
        rotate 30
        nocompress
        dateext
        dateformat _%Y%m%d
        extension .text
        missingok
        nocreate
        notifempty
}

I need to keep the last 30 days configs (texts) with each one containing the date when it was saved. I do not need to compress the files, I need all the texts in the same folder.

Anyone any ideas? Thanks in advance.

Andrew Schulman
  • 8,811
  • 21
  • 32
  • 47
IoNuTz
  • 11
  • 1
  • 1
    Does this answer your question? [log-rotation not working properly](https://serverfault.com/questions/997734/log-rotation-not-working-properly) – Andrew Schulman Apr 09 '21 at 13:11

1 Answers1

0

You can see here the problem of using *.text instead of a more concrete reference to the files you want to rotate

J.M. Robles
  • 925
  • 6
  • 9