xyz
xyz

Reputation: 782

What are the user's (SQL) roles needed to take SQL Server database backup using SMO Backup class?

What are the user's (SQL) roles needed to take a SQL Server database backup using the SMO Backup class in C# as shown below? Does it use Windows authentication?

 Server myServer = new Server(servername);

 Backup bkp = new Backup();
 bkp.Action = BackupActionType.Database;

 Database myDatabase = myServer.Databases[database];

 bkp.Database = myDatabase.Name;
 bkp.Devices.AddDevice(path, DeviceType.File);
 bkp.BackupSetName = string.Format("{0} database Backup", database);
 bkp.BackupSetDescription=string.Format("{0} database - Full Backup", database);
 bkp.Initialize = true;

 bkp.SqlBackup(myServer);

Upvotes: 1

Views: 1479

Answers (1)

gofr1
gofr1

Reputation: 15977

To be able to run BACKUP DATABASE and BACKUP LOG user must be members of the sysadmin fixed server role and the db_owner and db_backupoperator fixed database roles. From MSDN

Upvotes: 1

Related Questions