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
 SQL Server 2005 Forums
 SQL Server Administration (2005)
 Direct SQL BackUp to Network Drive

Author  Topic 

pradeep_iete
Yak Posting Veteran

84 Posts

Posted - 2009-01-14 : 23:06:45
Hi All,

I want to take full back up directly to my network drive.But it is giving me operating system error.

Suggest me the solution ?

sodeep
Master Smack Fu Yak Hacker

7174 Posts

Posted - 2009-01-14 : 23:09:11
quote:
Originally posted by pradeep_iete

Hi All,

I want to take full back up directly to my network drive.But it is giving me operating system error.

Suggest me the solution ?



What is the error? Backup to local drives wherever you have space and copy it to Network share.
Go to Top of Page

tkizer
Almighty SQL Goddess

38200 Posts

Posted - 2009-01-14 : 23:16:01
BACKUP DATABASE dbName
TO DISK = '\\Server1\Share1\dbName.bak'
WITH INIT

Tara Kizer
Microsoft MVP for Windows Server System - SQL Server
http://weblogs.sqlteam.com/tarad/

Subscribe to my blog
Go to Top of Page

pradeep_iete
Yak Posting Veteran

84 Posts

Posted - 2009-01-14 : 23:32:44
When I executed above command as suggested by tkizer following error is thrown by SQL server :

( Operating system error 53(The network path was not found.)
Go to Top of Page

sodeep
Master Smack Fu Yak Hacker

7174 Posts

Posted - 2009-01-15 : 06:31:29
Does that UNC path exist? or SQL Server has permission to it.
Go to Top of Page

SwePeso
Patron Saint of Lost Yaks

30421 Posts

Posted - 2009-01-15 : 06:55:01
Permission errors are most often #5 error number.


E 12°55'05.63"
N 56°04'39.26"
Go to Top of Page

darkdusky
Aged Yak Warrior

591 Posts

Posted - 2009-01-15 : 10:03:04
Check SQL Server Service account (Control Panel/ Admin Tools /Services) has access to the path. Alternatively you can run a script (DOS or vb etc) to copy backup file to network drive.

Here is a vbscript file which copies the most recent backup file across network.
This pulls backup file from remote to local, but could be changed to push.
It can be schedules with windows scheduler:



Dim FolderPath
Dim MostRecentFileName , LastModifiedFilePath , LastModifiedFileDate
Dim ErrorFound
Dim msg , tempstring


FolderPath = "\\Server\sql\BACKUP\DBNAME"
NewFolderPath = "c:\temp\BACKUP\DBNAME"


Dim FSO
Dim FolderFile , ThisFileName, PreviousFilename, MostRecentDate
MostRecentDate = now -5

On Error Resume Next
Set FSO = CreateObject("Scripting.FileSystemObject").GetFolder(FolderPath)
PreviousFileName =""
'bubble sort to find most recent
For Each FolderFile In FSO.Files
With FolderFile
ThisFileName = .Name
If .DateLastModified > MostRecentDate AND ucase(right(ThisFileName,4)) = ".BAK" AND left(ThisFileName,7) = "DBNAME_db_" Then
MostRecentDate = .DateLastModified
MostRecentFileName = ThisFileName
End If

End With
Next
Set FSO = Nothing
Set FolderFile = Nothing
Set FolderSubFolder = Nothing

Set fsoc = CreateObject("Scripting.FileSystemObject")
fsoc.deletefile NewFolderPath & "\*.*", TRUE
fsoc.copyfile FolderPath & "\" & MostRecentFileName ,NewFolderPath & "\" & MostRecentFileName

Set fsoc = Nothing


Go to Top of Page
   

- Advertisement -