Tydda Jon - Slough
jon.tydda at lonza.com
Fri Jul 20 03:50:41 CDT 2012
Thanks Mark - I spoke to my server guy, and he introduced me to the concept of "Forfiles": forfiles /P "C:\folder" /S /M *.ekb /D -35 /C "cmd /c del @file" This searches the C:\folder location for any .ekb files older than 35 days and deletes them. Pretty awesome stuff, and free with Windows 7! Jon -----Original Message----- From: dba-tech-bounces at databaseadvisors.com [mailto:dba-tech-bounces at databaseadvisors.com] On Behalf Of Mark Breen Sent: 20 July 2012 09:16 To: Discussion of Hardware and Software issues Subject: Re: [dba-Tech] Batch script help Hello John, If you are using SQL Server, take a look at expressmaint, it is opensource and does everything you can ask for re backups on SQL Server. It is really super. If Expressmaint does not do the job, then see see I am sorry that I cannot credit the site I caught this snippit from, but I have been using it daily for two years and it works great. Can you adjust it to do what you want ? <snip> :: This file just sets the folder and then identifies the latest file and then copys it. @echo off setLocal EnableDelayedExpansion pushd C:\MyFolder\ for /f "tokens=* delims= " %%a in ('dir/b/od *.sql') do (set newest=%%a) copy "%newest%" C:\FilesToRestore\db.sql </snip> Mark On 19 July 2012 10:34, Tydda Jon - Slough <jon.tydda at lonza.com> wrote: > Hi all > > > I've created a scheduled task to copy local database backup files to a > network drive so they get backed up for longer. That bit is easy. > > What I really want to do is to limit the folder to the last five > backups, so that I'm not filling the file server (and all the hourly > snapshots) with old data that won't ever be looked at again. > > I've searched for a script to delete the oldest file in a folder, but > with no joy - I'm trying to do this with a batch command (Windows 7). > > Can anyone help? > > > Jon > > > > ________________________________ > This communication and its attachments, if any, may contain > confidential and privileged information the use of which by other > persons or entities than the intended recipient is prohibited. If you > receive this transmission in error, please contact the sender > immediately and delete the material from your system. > _______________________________________________ > dba-Tech mailing list > dba-Tech at databaseadvisors.com > http://databaseadvisors.com/mailman/listinfo/dba-tech > Website: http://www.databaseadvisors.com > _______________________________________________ dba-Tech mailing list dba-Tech at databaseadvisors.com http://databaseadvisors.com/mailman/listinfo/dba-tech Website: http://www.databaseadvisors.com This communication and its attachments, if any, may contain confidential and privileged information the use of which by other persons or entities than the intended recipient is prohibited. If you receive this transmission in error, please contact the sender immediately and delete the material from your system.