I have a directory that I want to archive. A rotate archive. Never more than 8 files, and each file would have the date of archive in its name. Example:
1_2010_08_01_17h35m26s_archive.tar.bz2
2_2010_08_02_17h34m12s_archive.tar.bz2
3_2010_08_03_17h35m13s_archive.tar.bz2
4_2010_08_04_17h35m24s_archive.tar.bz2
5_2010_08_05_17h34m57s_archive.tar.bz2
6_2010_08_06_17h35m29s_archive.tar.bz2
7_2010_08_07_17h35m13s_archive.tar.bz2
8_2010_08_08_17h35m18s_archive.tar.bz2
And the next archive would delete the 8th file, rename every file to (n+1) then create the new one with name like 1_yyyy_mm_dd_HHhMMmSSs_archive.tar.bz2
NB: I've already looked to some logrotate scripts but none of them to exactly this.
Any idea where I should look?
Thanks again
With a custom shell script. You should only translate what you write above in shell command. Here you can find a good beginners guide on shell scripting.
It doesn't fit your request entirely, but logrotate configured with
dateext
rotates files like this:Digest from
man logrotate
:Archive old versions of log files adding a daily extension like YYYYMMDD instead of simply adding a number.