[dba-Tech] Batch script help

Mark Breen marklbreen at gmail.com
Fri Jul 20 03:16:17 CDT 2012


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
>


More information about the dba-Tech mailing list