Skip site navigation (1)Skip section navigation (2)
Date:      Mon, 20 May 2013 16:00:06 +0200
From:      Leslie Jensen <leslie@eskk.nu>
To:        =?ISO-8859-1?Q?Miguel_Barbosa_Gon=E7alves?= <m@mbg.pt>
Cc:        FreeBSD Questions <freebsd-questions@freebsd.org>
Subject:   Re: Delete files with time stamp on Samba Server
Message-ID:  <519A2C66.9090506@eskk.nu>
In-Reply-To: <CAEdntmtD6gzqnJp9zCy6w-rh3WFUU3_tu76Pr7j3UG8_kcBq=g@mail.gmail.com>
References:  <519A1843.3070808@eskk.nu> <CAEdntmtD6gzqnJp9zCy6w-rh3WFUU3_tu76Pr7j3UG8_kcBq=g@mail.gmail.com>

next in thread | previous in thread | raw e-mail | index | archive | help


2013-05-20 15:52, Miguel Barbosa Gonçalves skrev:
> On 20 May 2013 13:34, Leslie Jensen <leslie@eskk.nu> wrote:
>
>>
>> I have a remote Samba Server where Windows machines place backup files
>> once a day. The format is
>>
>>
>> backup_2013-05-03_13.45.44_.**zip
>>
>>
>> Before the Windows client places the file it removes the file from the day
>> before.
>>
>> In turn I do a backup of the backup files once every week(Friday) to
>> another directory.
>>
>> This directory will eventually fill up and I need to make a check and
>> remove the oldest file maybe once a week before the new file is copied, or
>> put in other words I never want more than 4 files to be in this directory.
>>
>> My scripting skills are not at the level where I can figure this out, so
>> I'll appreciate suggestions on how to solve this in the correct way.
>>
>
>
> Hi Leslie!
>
> I believe this is what you need:
>
> --- START ---
> #!/bin/sh
>
> KEEP='5'
>
> pg_dump -U gp > /backups/gp.`date +%Y%m%d-%H%M%S`.sql
>
> N=1
> for file in `ls -r /backups/gp.*`
> do
>         [ $N -gt $KEEP ] && rm -f $file
>         N=`expr $N + 1`
> done
> --- END ---
>
> I am using this to keep 5 backup files... Modify as needed.
>
> Cheers,
> Miguel
> _______________________________________________
> freebsd-questions@freebsd.org mailing list
> http://lists.freebsd.org/mailman/listinfo/freebsd-questions
> To unsubscribe, send any mail to "freebsd-questions-unsubscribe@freebsd.org"
>

Thanks Miguel

I'll see what I can do with it.

/Leslie




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?519A2C66.9090506>