Hazem Rashad
Hazem Rashad

Reputation: 11

can't run sql backup script on shared hosting

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

Answers (1)

podiluska
podiluska

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

Related Questions