Reputation: 11
I can't run SQL backup script on shared hosting through asp.net website
This is the error message:
BACKUP DATABASE permission denied in database 'TestDB'.
BACKUP DATABASE is terminating abnormally.
This is the code:
sqlcon.Open();
//query to take backup database
sqlcmd = new SqlCommand("backup database TestDB to disk='" + destdir + "\\" + dbname + "_" + DateTime.Now.ToString("ddMMyyy") + ".Bak'", sqlcon);
sqlcmd.ExecuteNonQuery();
//Close connection
sqlcon.Close();
Upvotes: 1
Views: 328
Reputation: 51504
The user account you are connecting with doesn't have the permission to do a backup.
(That's what the error says)
Only users who are members of db_owner
or db_backupoperator
have the backup database
permission by default.
Your hosting provider will probably provide some other backup mechanism.
Upvotes: 1