Re: shell cript deleting backups
On Tue, Jun 07, 2005 at 01:06:15AM +0200, mess-mate wrote:
> David Jardine <david@jardine.de> wrote:
> | On Mon, Jun 06, 2005 at 07:20:06AM -0700, Alvin Oga wrote:
> | >
> | >
> | > On Mon, 6 Jun 2005, mess-mate wrote:
> | >
> | > > Alvin Oga <aoga@mail.Linux-Consulting.com> wrote:
> | > > |
> | > > | save it as
> | > > |
> | > > | /backup/mon
> | > > | /backup/tue
> | > > | /backup/wed
> | >
> | > ...
> | >
> | > > But can't save as /backup/mon, etc.. There is nochoice about the
> | > > backup name except the primairy name = 'Maildir', with konserve.
> | > > 'Maildir' is directory ( ~/Maildir/INBOX.debian )
> | >
> | > there is always a choice ... too many gazillion choices.. its *unix*
> | >
> | > > I'm looking for a simple backup package independant of KDE.
> | >
> | > #
> | > # whacky script for ~/Maildir
> | > #
> | > #
> | > # for using date: 1, 2, 3, ... 30
> | > # pkg=`date '+%d'`
> | > #
> | > # for using mon, tue, wed
> | > # pkg=`date '+%a'`
> | >
> | > tar zcvf /backup/pkg.tgz /home/~/Maildir
> |
> | I'm always trying to learn something from you experts, but I
> | don't understand the above command. Is it right? I would
> | have expected
> |
> | tar zcvf /backup/pkg.tgz /home/*/Maildir
> |
> | to save everyone's files, or
> |
> | tar zcvf /backup/pkg.tgz ~/Maildir
> |
> | for a user to save his own files.
> |
> | Was it a typo, or is this my ignorance?
> |
> Yes it's a typo :)
> Must be tar zcvf ~/Backups/Maildir-date '+%d'.tgz ~/Maildir
> But the way i want is as follows:
> Add number 1 to the backup file and when backup next that file,
> delete the newer one(s) and restart with number 1.( the number 1
> file will be automatically overwrite )
> Say 1-maildir.tgz as first, the next backup verify if there are
> newer (greater of nbr 1) and delete them first and recreate
> with nbr 1 = 1-maildir.tgz.
> (This incase if older backups wheren't deleted before )
I haven't really been following the thread, so I'm not sure what
you want but would something like the following (perl) script
do it as a cron job? A shell script would be simpler, I'm sure,
but that's beyond me :(
#!/usr/bin/perl -w
$num=5; // the number of days (weeks...) you want to keep
while(--$num>0){
my $vieux_nom="/backup/$num-maildir.tgz";
my $nouveau_nom="/backup/".($num+1)."-maildir.tgz";
system("mv $vieux_nom $nouveau_nom 2>/dev/null");
}
system("tar czf /backup/1-maildir.tgz /home/*/Maildir/");
>
> mess-mate
> --
> You will be held hostage by a radical group.
>
>
> --
> To UNSUBSCRIBE, email to debian-user-REQUEST@lists.debian.org
> with a subject of "unsubscribe". Trouble? Contact listmaster@lists.debian.org
>
--
David Jardine
"Running Debian GNU/Linux and
loving every minute of it." -L. von Sacher-M.(1835-1895)
Reply to: