revelvice
revelvice

Reputation: 368

Backup and restore MS SQL database

Situation is simple.
I have application in C# that use MS SQL Database. For some reason i need to add some backup/restore function. I don't have directly access to MS SQL instance.

Is there any other simply way to backup database from C#? Maybe some script can create tables, structures and data, that can be use on other machine?

I need to do this only via C# (standard .NET references). No third party applications.

Upvotes: 2

Views: 1212

Answers (2)

Mitch Wheat
Mitch Wheat

Reputation: 300499

You can use SMO for this (provided you have the appropriate access permissions):

To run the SqlBackup method, users must have BACKUP DATABASE or BACKUP LOG permissions on the database, or be a member of the db_owner and db_backupoperator fixed database role and the sysadmin fixed server role.

Also:

C# SMO backup of remote database to local machine.

Getting Started with SMO in SQL 2005 - Backups

Upvotes: 1

user596075
user596075

Reputation:

No, there isn't.

If you don't have permissions or even a login to the SQL Server instance, you will not be able to run any sort of BACKUP commands against the database.

Backing up the file system (the mdf, ldf, and ndf's) isn't a sufficient backup strategory for SQL Server.

Upvotes: 3

Related Questions