Brij
Brij

Reputation: 13151

Can we use SMO to take backup of database located at hosting server?

I followed the examples from http://msdn.microsoft.com/en-us/magazine/cc163409.aspx

I am creating a utility that creates backup of databases (local or remote). I was able to create backup of databases located at my local server. But when I do so for databases located at host server I get following error:

System.Data.SqlClient.SqlError: Cannot open backup device 'D:\Brij\Docs\MyDb.bak'. Operating system error 21(The device is not ready.).

Looks like SMO creates the backup file where the server is located, and hence it is not finding the path. Am I correct ? How could I take backup of a database from a host server and get the backup file in my local machine ?

Upvotes: 0

Views: 177

Answers (1)

Ben Thul
Ben Thul

Reputation: 32717

Backup paths are always relative to the server. You can backup to UNC (which I do personally, even if it's a local UNC) or, if you're on a sufficiently recent build of SQL 2012, Azure blob storage (http://technet.microsoft.com/en-us/library/jj919148.aspx).

Upvotes: 1

Related Questions