1 (edited by RobLarge 25-02-2011 09:44:38)

Re: Still can't restore backups

Posting this question again (fifth time?), because I have had no useful response AT ALL.

We still have an issue with backups, in that I can create a backup successfully, but when I try to restore from it I get a message that "Failed to backup database as you do not have permission" As far as I am aware I have all necessary permissions and I do not get this message when I do the backup, only the restore.

There has to be a clue there, since I am not trying to create a backup I am trying to restore one, so this message looks like it was triggered in error.

I have checked the backup file, it is of the expected size and the datestamp looks as if it was created at the precise time I requested it. As far as I can tell I have a valid backup.  My only possible course of action now is to try and restore the backup file onto my standalone copy of Recorder to determine if it is indeed a valid backup file.

This fault is making me very nervous about making any significant changes to the database, although we have daily backups of our whole network, that is not a substitue for being able to back up and restore on demand. Restoring from the daily backup potentially results in the loss of five people's work for the day.

????

Rob Large
Wildlife Sites Officer
Wiltshire & Swindon Biological Records Centre

2

Re: Still can't restore backups

Complete stab in the darks and I haven't been reading your other threads (in case they give me nightmares)....

What format is the backup? Is it an access database? I wonder if Recorder is trying to alter the database file (with linked tables?) rather than just reading it - might explain the permissions error?

Charlie Barnes
Information Officer
Greater Lincolnshire Nature Partnership

3

Re: Still can't restore backups

No as far as I can tell Recorder uses SQL server to manage the backup and the file generated is called NBNData.bak. The file is about the same size as the main database file and is generated pretty quickly, so I imagine the backup routine just detatches the database file from the server and makes a copy of it, before re-attaching it.

I'm not sure there even is a real permissions issue. We have only found one backup-related permission setting in SQL server, db_backupoperator and we have assigned this both to my login and to NBN_User. I know this works because I created the SQL server backup device, without this I was unable to generate the backup in the first place.

Interestingly if I try to restore while there is someone else logged in there is a long pause before I am told that the restore is not possible. If no-one else is logged in I get the "don't have permission" message immediately with no pause. It looks to me like when someone else is logged in the UI asks SQL server to restore and it refuses, while if no-one is logged in, the UI doesn't even bother to ask, just tells me I can't.

Rob Large
Wildlife Sites Officer
Wiltshire & Swindon Biological Records Centre

4

Re: Still can't restore backups

I just noticed that in the Recorder help it says that the default name of the backup file should be NBNBackup.bak, not NBNData.bak as we had it set.

I changed the backup device accordingly and it made not the slightest bit of difference. I still can create backups, but not restore them.

God I am getting sick of this!

Rob Large
Wildlife Sites Officer
Wiltshire & Swindon Biological Records Centre

5

Re: Still can't restore backups

Assuming Recorder isn't doing anything fancy with the backup process... http://stackoverflow.com/questions/4908602/sql-server-2005-backup-restore-failing-with-folder-permissions says

The account running the SQL Server service requires permissions on that folder.

You may be connected to SQL Server, but actions are done in the service account context: not you.

Run services.msc from command line, see what account is used, permission this folder accordingly.

Charlie Barnes
Information Officer
Greater Lincolnshire Nature Partnership

6

Re: Still can't restore backups

Also in the help file it says

Recorder 6 allows users with system administrator access to view and change the location where this backup is placed.

I am a system administrator, so why does Recorder also tell me I cannot change the backup location because I do not have permission?

Rob Large
Wildlife Sites Officer
Wiltshire & Swindon Biological Records Centre

7

Re: Still can't restore backups

Thanks Charlie

Not sure I really understand those lines you quote, but I told our ITC and he seemed to have a better understanding.

We'll see...

Rob Large
Wildlife Sites Officer
Wiltshire & Swindon Biological Records Centre

8

Re: Still can't restore backups

RobLarge wrote:

Not sure I really understand those lines you quote.

Neither did I....:rolleyes:

Charlie Barnes
Information Officer
Greater Lincolnshire Nature Partnership

9

Re: Still can't restore backups

Didn't make any difference anyway....

Rob Large
Wildlife Sites Officer
Wiltshire & Swindon Biological Records Centre

10

Re: Still can't restore backups

Do you have access to the SQL management tool? Can you restore the backups that way?

Quoting from the Recorder help:

In a standard Recorder installation the database will be a file called NBNData_Data.MDF and associated with it will be a log file called NBNData_log.LDF. In a standard MSDE installation where the option to specify your own instance name is set to RECORDER these files will be in C:\Program Files\Microsoft SQL Server\MSSQL$RECORDER\Data. If you have SQL Server tools such as Enterprise Manager (SQL Server 2000) or SQL Server Management Studio Express (SQL Server 2005) you will be able to use them for backing up your database. Alternatively you can use the facilities in Recorder 6.

Note: By default, in a standard standalone installation, a backup done in Recorder 6 will be a file called NBNBackup.bak in the Temp folder of the user who installed Recorder 6, e.g. C:\Documents and Settings\User Name\Local Settings\Temp.

I presume the former is referring to a standard network install - which are you using, network or standalone?

Charlie Barnes
Information Officer
Greater Lincolnshire Nature Partnership

11

Re: Still can't restore backups

I have tried restoring backups with SQL server tools, but haven't succeded so far (people keep loggin in - users eh?).

Ours is networked and the backup files are in a different folder, but there are no permission issues in that folder I am quite sure.

Rob Large
Wildlife Sites Officer
Wiltshire & Swindon Biological Records Centre

12

Re: Still can't restore backups

I'm confusing myself now... Where should a backup of a network installation go/be?

RobLarge wrote:

the backup files are in a different folder

Just a though - I wonder if the path is hard coded into Recorder......

Charlie Barnes
Information Officer
Greater Lincolnshire Nature Partnership

13 (edited by RobLarge 25-02-2011 15:43:56)

Re: Still can't restore backups

No I don't think so. The backup is managed by a "backup device", which is a SQL server object, not actually part of the database. This device specifies where the backup will go (path and filename). Normally this is created at install time and the backup probabaly goes into the default location you describe.

There is however an option (on the tools/database tools menu) to change the default backup location and we did this some time ago, when everything still worked, to put it in a more memorable location. As far as I know it worked fine after we moved it.

A couple of months ago we got a brand new server (and new SQL server) and everythying went horribly wrong for a bit as our old SQL server hive became corrupt during an attempted transfer and fell over, losing everything (we had backups).

Much tech support later the new SQL server works and the Recorder db also, except that in the transfer the backup device had been lost. No matter, it is the work of a few moments to create a new one and we have done so. But it won't restore anymore and I cannot change the backup location from within recorder either.

That's how I got to where I am now, I know rather more about SQL server than I really need to now.  But I have posted in the hope that someone whose job it is to trace and even fix problems like this will reply to my post (while there are still people being paid to do that). I would have thought that the thread above contains enough information to be able to track down what permission I do not have which I need.

No offence intended to you Charlie, or to the admins here who do a great job, but they have been noticeably quiet on this one, which is why I keep reposting.

Rob Large
Wildlife Sites Officer
Wiltshire & Swindon Biological Records Centre

14

Re: Still can't restore backups

Rob

This looks like a similar problem to that reported in http://forums.nbn.org.uk/viewtopic.php?id=1677 for which I have not found a solution.

The basics are that you must have a backup device (set up via Server Objects/Backup Devices) called NBNData_Backup  This must have a file destination. Usually deleting this device and then setting it up again will solve backup problems, but this hasn't worked in the situation described in topic 1607. Some more clues as to why this is the case are required.

Recorder executes the following to do the restore   

Restore Database "NBNData" from "NBNData_Backup" 

You could try running this directly from within Management studio (against the Master database with Recorder closed)  and it may give some furrher information which will help find the problem.

To get the location of the backup file Recorder Executes

Select phyName from master.dbo.sysdevices where name = 'NBNData_backup'

Running this from within Managment Studio will show you if you have a valid device set up or not.


Mike

Mike Weideli

15

Re: Still can't restore backups

Hi Rob so caught up in importing I had not thought I could help with your problem. Then I realised today that I may have the same issue. When I could not do the backup in the past I went ahead an did it in SQL Manager.

So now I'm wondering if any of my backups can be restored. I will attempt to have look at Mikes suggestion myself. It may be a while though.

Data Manger
Somerset Environmental Records Centre

16

Re: Still can't restore backups

Hi Rob & Tony
A quick summary of the permissions required might help. In order to make a backup, you need db_backupoperator permissions on the NBNData database. In order to restore it though, you need db_owner permissions on the NBNData database. Backupoperator is not enough otherwise someone with backupoperator privileges could restore a copy that increases their own privileges to db_owner. This is likely to be the problem - because you are logging in as NBNData the default permissions for NBNData do not include db_owner rights. My suggestion would be rather than to use db_owner for the NBNUser login, Recorder should ask you for the sa login when restoring a database so I will make this suggestion on the issues list. However for now adding the db_owner role to the NBNUser login should do the job.

For completeness, changing the directory of the backup also requires the server-level diskadmin role.

Best Wishes

John

John van Breda
Biodiverse IT

17

Re: Still can't restore backups

Thanks Mike and John

Sorry about the slightly grumpy rant, but it served its purpose apparently.

Useful responses from both of you, but since I am away from the office for a few days I cannot check whether anyone else is logged in easily, so testing will have to wait until after hours.

Unfortunately John your summary of permissions doesn't help as both my login and the NBNUser have dbowner  already, but I still cannot do the restore. I will check whether the diskadmin role makes any difference to the ability to change the backup location anyway.

I repeat my conjecture that this is not (or not entirely) a permissions issue, it feels like a bug to me.

John, since you have access to the source code, would you be able to look for the message dialog I am receiving, which says  verbatim "Failed to backup database as you do not have permission" and find out under what circumstances it would be triggered by an attempt to restore (rather than create) a backup. It may of course be just sloppy programming and the message may have been recycled from an exception trap on the backup operation, if that is the case, then it should be easily corrected even if it doesn't help me with this problem. It seems to me that the dialog ought to report which permission is needed rather than just telling me I can't.

Mike, later tonight I will attempt to run the restore directly through Management Studio and see what error messages that delivers, if any.

Thanks to you both.

And Tony, who knows what horros await after the importing is done, watch this space.

Rob Large
Wildlife Sites Officer
Wiltshire & Swindon Biological Records Centre

18

Re: Still can't restore backups

Hi Rob
You are correct about a sloppy copy and paste meaning you get the wrong error message. I've corrected this in the code but as you say it does not help much. The error message it is trapping is definitely "User does not have permission to RESTORE database."
Actually on my own tests, using SQL Express 2005 running on Windows 7 64 bit, logging in using NBNUser to backup and restore works (though I moved the backup location to c:\temp). I am using the default permissions for NBNUser:
Rights on NBNData include db_backupoperator, db_datareader, db_datawriter, db_ddladmin.
Rights on the server login include dbcreator, diskadmin and public.

Not having dbcreator rights does cause restore to fail even though backup succeeds, so this is quite a likely cause of the problem.

John van Breda
Biodiverse IT

19

Re: Still can't restore backups

Thanks John

We just arrived at the same conclusion. Sitting at home on my laptop I have a standalone install of Recorder which has server level roles as you describe dbcreator, diskadmin and public.

I have checked on the networked copy at work and it has no server-level roles assigned at all. Not all that surprising given that our setupwas transferred from one server to another as I described.

I can't make the changes from here but have requested them, I will post as soon as I have an answer.

Rob Large
Wildlife Sites Officer
Wiltshire & Swindon Biological Records Centre

20

Re: Still can't restore backups

And now everything works as it should. I have successfully backed up the db and restored it and I can change the backup location at will. It was indded the server-level dbcreator role that was missing.

Thanks everyone for your help.

Rob Large
Wildlife Sites Officer
Wiltshire & Swindon Biological Records Centre