From owner-freebsd-questions@FreeBSD.ORG Mon May 20 14:00:53 2013 Return-Path: Delivered-To: freebsd-questions@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by hub.freebsd.org (Postfix) with ESMTP id B3B18A0A for ; Mon, 20 May 2013 14:00:53 +0000 (UTC) (envelope-from leslie@eskk.nu) Received: from mx1.bjare.net (mx1.bjare.net [212.31.160.3]) by mx1.freebsd.org (Postfix) with ESMTP id 472D4B0E for ; Mon, 20 May 2013 14:00:53 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by mx1.bjare.net (Postfix) with ESMTP id C83805E55F; Mon, 20 May 2013 16:00:50 +0200 (CEST) X-Virus-Scanned: Debian amavisd-new at mx1.bjare.net X-Spam-Flag: NO X-Spam-Score: -0.966 X-Spam-Level: X-Spam-Status: No, score=-0.966 tagged_above=-999 required=5 tests=[AWL=0.032, BAYES_00=-2.599, RCVD_IN_PBL=0.905, RDNS_DYNAMIC=0.1, SPF_SOFTFAIL=0.596] Received: from mx1.bjare.net ([127.0.0.1]) by localhost (mx1.bjare.net [127.0.0.1]) (amavisd-new, port 10024) with LMTP id aTDiW52StLbq; Mon, 20 May 2013 16:00:42 +0200 (CEST) X-BN-MX1: ja X-BN-MailInfo: BjareNet Received: from bljbsd01.no-ip.org (c224-156-70-80.bjare.net [80.70.156.224]) by mx1.bjare.net (Postfix) with ESMTP id 449695E56F; Mon, 20 May 2013 16:00:34 +0200 (CEST) Message-ID: <519A2C66.9090506@eskk.nu> Date: Mon, 20 May 2013 16:00:06 +0200 From: Leslie Jensen User-Agent: Mozilla/5.0 (X11; FreeBSD amd64; rv:17.0) Gecko/20130516 Thunderbird/17.0.6 MIME-Version: 1.0 To: =?ISO-8859-1?Q?Miguel_Barbosa_Gon=E7alves?= Subject: Re: Delete files with time stamp on Samba Server References: <519A1843.3070808@eskk.nu> In-Reply-To: Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 8bit Cc: FreeBSD Questions X-BeenThere: freebsd-questions@freebsd.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: User questions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 20 May 2013 14:00:53 -0000 2013-05-20 15:52, Miguel Barbosa Gonçalves skrev: > On 20 May 2013 13:34, Leslie Jensen 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