Reputation: 368
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
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
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