1

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

Olivier Pons
  • 622
  • 1
  • 5
  • 22

2 Answers2

1

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.

lg.
  • 4,649
  • 3
  • 21
  • 20
  • Thanks for the link, I thought that someone else in the whole world may already have had such a need a I could find such a script. I'll check your answer if I can't find a script that does it and I end up writing my own... Thanks again – Olivier Pons Aug 02 '10 at 13:47
0

It doesn't fit your request entirely, but logrotate configured with dateext rotates files like this:

mainlog-20100720.gz
mainlog-20100721.gz
mainlog-20100722.gz
mainlog-20100723.gz
mainlog-20100724.gz
mainlog-20100725.gz
mainlog-20100726.gz

Digest from man logrotate:

Archive old versions of log files adding a daily extension like YYYYMMDD instead of simply adding a number.

mkudlacek
  • 1,677
  • 1
  • 11
  • 15