this post was submitted on 15 Apr 2025
5 points (100.0% liked)
Linux
1996 readers
1 users here now
Everything about Linux
RULES
-
Be nice to each other.
-
No memes or pictures of Linux in the wild.
founded 2 years ago
MODERATORS
you are viewing a single comment's thread
view the rest of the comments
view the rest of the comments
Unfortunately, logrotate does not work the way I would like it to. I have now created a bash script, which hopefully does what it is supposed to do:
Invoked in the respective directory, all *.db files are read into an array, as there can be different DBs per user. The array is then processed in a loop. First, the backup files for the respective DB are read into the array again, sorted by age. This array is then processed and all files whose index +1 is greater than keepCount are removed. This means that the oldest files are always removed and only those that are defined in the keepCount are kept.
Its a little bit more complicated, but it seems to do the job.