Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

VBScript to Backup SQL

Posted on 2012-03-22
2
Medium Priority
?
1,914 Views
Last Modified: 2012-03-23
Hello Experts,

Is it possible to create a VBscript to backup a SQL database?

Using the SQL backup in SQL Express 2008 R2 I was able to generate the following script and I would like to turn it into a VBS:

BACKUP DATABASE [db] TO  DISK = N'D:\db' WITH NOFORMAT, NOINIT,  NAME = N'db-Full Database Backup', SKIP, NOREWIND, NOUNLOAD,  STATS = 10
GO

Open in new window


As a final result I would like to add the VBS to Windows scheduler every 15 min. Is this a safe way to do it since my database is only 40mb, expecting it to grow maybe to 200 over the next year or two?

Lastly, I am wondering when the script creates this file, will I be able to just copy the backed up file and attach it to my development server without doing import/export?

Thanks
0
Comment
Question by:APD_Toronto
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 2

Accepted Solution

by:
Kelden earned 1500 total points
ID: 37755119
You can execute the task scheduler without a vbs. Just create a batch file and add the following:

set OSQL=%ProgramFiles%\Microsoft SQL Server\110\Tools\Binn\osql.exe
 "%OSQL%" -U "sa" -P "<password>" -S "." -d "master" -b -e -q "BACKUP DATABASE [db] TO  DISK = N'D:\db' WITH NOFORMAT, NOINIT,  NAME = N'db-Full Database Backup', SKIP, NOREWIND, NOUNLOAD,  STATS = 10"

Open in new window


you have to change the path to your osql.exe file.
-S is the instance name. use "." for no instance or ".\instancename" if you have one.
Use -E instead of -U and -P if you want to use a trusted connection.
0
 

Author Comment

by:APD_Toronto
ID: 37755209
can you please clarify?-
0

Featured Post

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

How to leverage one TLS certificate to encrypt Microsoft SQL traffic and Remote Desktop Services, versus creating multiple tickets for the same server.
When you see single cell contains number and text, and you have to get any date out of it seems like cracking our heads.
In response to a need for security and privacy, and to continue fostering an environment members can turn to for support, solutions, and education, Experts Exchange has created anonymous question capabilities. This new feature is available to our Pr…
We’ve all felt that sense of false security before—locking down external access to a database or component and feeling like we’ve done all we need to do to secure company data. But that feeling is fleeting. Attacks these days can happen in many w…

610 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question