Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 Backup and Restore Database using VB Script

Author  Topic 

newuser001
Starting Member

19 Posts

Posted - 2009-05-21 : 20:03:16
I am trying to backup and restore Database using VB Script........


i am trying as below:

Set objSQL = CreateObject("SQLDMO.SQLServer")
Set fso = CreateObject ("Scripting.FileSystemObject")
Set WshShell = CreateObject("WScript.Shell")
Set oBackup = CreateObject("SQLDMO.Backup")

sServer = "hqsqlbkup1"
sDatabase = "master"
sPath = "C:\DBA\"
sDumpFile = "master.dmp"
sDBUser="sa"
sDBPwd="sa"

objSQL.LoginSecure = True

objSQL.Connect sServer, sDBUser, sDBPwd
oBackup.database = sDatabase
oBackup.Action = SQLDMOBackup_Database
oBackup.BackupSetDescription = "Backup - " & sDatabase
oBackup.Files =sPath & sDatabase & ".bak"
oBackup.TruncateLog = "3"
oBackupInitialize="True"
oBackup.SQLBackup objsql

Is this the right way

getting Error:


its not working in network ....
when i go to the server and run script from server it works

i tried to shared the folder where the path is (\\serverName\\SQLScripts)
its giving error bad file name

when i try with sPath = "C:\DBA\"
its showing error on last line as -> NULL (oBackup.SQLBackup objsql)
   

- Advertisement -