Without a change to your process, logrotate on its own will not do what you're looking for here. The key problem here is that, while logrotate can take wildcards, it will not treat the files as one if you do so and will instead attempt to rotate all of them individually, which is definitely NOT what you want.
You can, however, make it work the way you describe as long as the most recent backup is created without a date stamp. If you backup process creates /root/backup.tar.gz
for instance, you could use the following logrotate configuration:
/root/backup.tar.gz {
rotate 5
nocompress
dateext
dateformat _%Y-%m-%d
extension .tar.gz
missingok
}
The quick rundown of the options here:
rotate 5
-- keep 5 rotations before deleting
nocompress
-- do not compress the files after rotating
dateext
-- use the date as the rotation extension instead of incrementing numbers
dateformat _%Y-%m-%d
-- set the date extension format you want to use
extension .tar.gz
-- make the .tar.gz
come after the rotation extension
missingok
-- if the file we want to rotate isn't there, don't worry about it and move on (the default is to throw an error)
Hope this helps!