Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How do I backup an online SQL MSDE DB?

Status
Not open for further replies.

danjwalker

IS-IT--Management
Mar 22, 2005
44
0
0
GB
I have some work to do for a firm. They use an MSDE SQL database runnning on MSDE2000. It is only used in business hours so, if possible, it is ok to take it offline to back it up.

So, my question is this: With Microsoft Backup that comes with Win2k Server, can I back this sql database up?
Do I need to take the DB offline?
If I do, is there a script I can write to do this?

I wish to backup to a tape drive.

Thanks,
 


Dim oServer
Dim oDatabase
Dim oBackup
Dim sBAKFilePath

'change this to where ever you want to place your backup files, no trailing
'backslash, we add it below

sBAKFilePath = "C:\BackUp"

'we need a backup object in addition to the sqlserver one

Set oServer = CreateObject("SQLDmo.SqlServer")
Set oBackup = CreateObject("SQLDmo.Backup")
oServer.LoginSecure = True
oServer.Connect "(local)"

'this will do a full backup of every database except TempDB to a file


For Each oDatabase In oServer.Databases
If UCase(oDatabase.Name) <> "TEMPDB" Then
oBackup.Database = oDatabase.Name
'remove any previous backup - same as using T-SQL with init
oBackup.Initialize = True
'dynamically create the name of the backup file
oBackup.Files = sBAKFilePath & "\" & oDatabase.Name & ".bak"
'set the action property as needed
'0 = Full backup
'1 = Differential
'2 = Specified files only
'3 = Log backup
oBackup.Action = 0
oBackup.SQLBackup oServer
End If
Next

'clean up
Set oBackup = Nothing
oServer.DisConnect
Set oServer = Nothing
MsgBox "Database BackUps Done"
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top