Take the 2-minute tour ×
Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

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

share|improve this question

2 Answers 2

up vote 1 down vote accepted

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.

share|improve this answer
    
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 2 '10 at 13:47

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.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.