[CentOS] Bash script for backup

Mon Jan 25 21:06:10 UTC 2010
Christoph Maser <cmr at financial.com>

Am Montag, den 25.01.2010, 19:48 +0100 schrieb Alan Hoffmeister:
> Hello guyz!
>
> I'm new here, and this is my very first truble...
>
> I need a script that will backup & compress the folder /media/system in
> the folder /media/backups
>
> But that's not the problem, I need that only the last 7 backups (last 7
> days, yeah I know, cronjob...) will stay in that folder...
>
> The script need:
> 1 - Compress folder /media/system
> 2 - Store in /media/backups
> 3 - Name the compressed backup like day_month_year.tar.gzip
> 4 - Check the other backups and delete backups older than 7 days..
>
> Can some one help me?
>
> Tanks!

Since it is 7 days you want putting `date +%A` in the output filename
would be an easy solution. Another really simple thing is to use the
--backup switch of mv.

Chris


financial.com AG

Munich head office/Hauptsitz München: Maria-Probst-Str. 19 | 80939 München | Germany
Frankfurt branch office/Niederlassung Frankfurt: Messeturm | Friedrich-Ebert-Anlage 49 | 60327 Frankfurt | Germany
Management board/Vorstand: Dr. Steffen Boehnert | Dr. Alexis Eisenhofer | Dr. Yann Samson | Matthias Wiederwach
Supervisory board/Aufsichtsrat: Dr. Dr. Ernst zur Linden (chairman/Vorsitzender)
Register court/Handelsregister: Munich – HRB 128 972 | Sales tax ID number/St.Nr.: DE205 370 553