The forum will experience an outage sometime between February 10 at 7:00pm EST and February 12 at 11:59 EST for installation of security updates. The actual time and duration of the outage are unknown but attempts will be made to minimize the downtime. We apologize for any inconvenience.

Hi all

I am trying to create a batch file that will create a folder of todays date, then backup the db file to that folder, something along the lines of..

setlocal enableextensions
set name=%DATE:/=_%
mkdir %name%
dbbackup -c "uid=DBA;pwd=SQL;dbn=BrewMasterWorld" %name%

Appreciate any guidance on this

Thanks

C

asked 31 May '16, 12:04

Colin%20M's gravatar image

Colin M
11
accept rate: 0%

edited 31 May '16, 12:22

Mark%20Culp's gravatar image

Mark Culp
22.3k9129262


IMHO that looks ok, but you might want to add the eng={enginename} parameter to the connection string.

Another approach would use an SQL statement for that purpose:

 
create variable @path varchar(127);
set @path= String('C:\Backup\',dateformat(today(),'mm_dd_yyyy'));
backup database directory @path
This could be executed as a batch with ISQL.

permanent link

answered 01 Jun '16, 05:04

Reimer%20Pods's gravatar image

Reimer Pods
4.1k324278
accept rate: 12%

Your answer
toggle preview

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Markdown Basics

  • *italic* or _italic_
  • **bold** or __bold__
  • link:[text](http://url.com/ "title")
  • image?![alt text](/path/img.jpg "title")
  • numbered list: 1. Foo 2. Bar
  • to add a line break simply add two spaces to where you would like the new line to be.
  • basic HTML tags are also supported

Question tags:

×5

question asked: 31 May '16, 12:04

question was seen: 151 times

last updated: 01 Jun '16, 05:04