Solved

VBScript to Backup SQL

Posted on 2012-03-22
2
1,757 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
2 Comments
 
LVL 2

Accepted Solution

by:
Kelden earned 500 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

Free Gift Card with Acronis Backup Purchase!

Backup any data in any location: local and remote systems, physical and virtual servers, private and public clouds, Macs and PCs, tablets and mobile devices, & more! For limited time only, buy any Acronis backup products and get a FREE Amazon/Best Buy gift card worth up to $200!

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
SQL Server 2008 R2 - Execution Plan 3 29
CREATE DATABASE ENCRYPTION KEY 1 44
Log Backup 2 13
Sql query for filter 12 22
SQL Server engine let you use a Windows account or a SQL Server account to connect to a SQL Server instance. This can be configured immediatly during the SQL Server installation or after in the Server Authentication section in the Server properties …
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
This video demonstrates how to create an example email signature rule for a department in a company using CodeTwo Exchange Rules. The signature will be inserted beneath users' latest emails in conversations and will be displayed in users' Sent Items…
You have products, that come in variants and want to set different prices for them? Watch this micro tutorial that describes how to configure prices for Magento super attributes. Assigning simple products to configurable: We assigned simple products…

705 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

Need Help in Real-Time?

Connect with top rated Experts

13 Experts available now in Live!

Get 1:1 Help Now