Re: [Nolug] enumerating tar backups

From: Andrew S. Johnson <andy_at_asjohnson.com>
Date: Sun, 14 Dec 2003 14:56:11 -0600
Message-Id: <200312141456.11929.andy@asjohnson.com>

On Sunday 14 December 2003 01:22 pm, Petri Laihonen wrote:
> Hi all!
>
> Does anybody on the list happen to know command syntax for taking enumerated
> backups using tar, so that I would only have 3 days worth of backups
> available all the time.?
>
> I have not found a tar manual explaining the method of doing this.
> The option --backup=METHOD suggest along these lines, but I have not found
> any list of allowed methods or other parameters for creating this.
>
> Currently I have tar automatically create the date into the filename;
> however this would consume the available HD space within a week. (Including
> mirror for backups.)
>
> What I'm trying to do is to create 3 rotating backups,
> Day 1: Backup_01.tgz (eventually Days 4, 7, 10, etc....)
> Day 2: Backup_02.tgz (eventually Days 5, 8, 11, etc....)
> Day 3: Backup_03.tgz (eventually Days 6, 9, 12, etc....)
>
> And when the fourth backup occurs, the backup_01.tgz will be overwritten.
> The next day backup _02.tgz will be overwritten, and so on.....
>
>
> Petri
>
At work, I keep 7 days worth of backups, and use the day of the week
in the name. That way, it's easy to tell what backup was made on which
day. If you really only want three, then you could do some math using
the time since epoch in seconds divided by 86400 modulus 3 plus 1:

$ echo Backup_0$(((`date +%s`/86400)%3+1)).tgz
Backup_02.tgz

Andy Johnson

___________________
Nolug mailing list
nolug@nolug.org
Received on 12/14/03

This archive was generated by hypermail 2.2.0 : 12/19/08 EST