We have an application which is currently deployed using SQL Server 2016.
As part of its features a user connected to a Support website is able to backup and restore the database.
The webservice relays the request to a Windows Service, running as SYSTEM, which actually performs the task. The backup is saved to a file named with the date and time of the backup. Prior to the restore, the database is placed into Single User Mode.
In SQL Server 2016 this works as expected.
We now want to port to 2019.
Backups are performed OK, but when we want to restore the database the Windows Service gets the error: User does not have permission to RESTORE database 'XXX'
The file identified as the source of the restore does exist and has the following security:
- SYSTEM : Allow everything
- MSSQLSERVER : allow everything
- Administrators : allow everything
- UserX (what I log onto the machine as) : allow everything
I tried using SQL Management Studio (running as Administrator) and connecting with Windows Authentication using UserX (so not quite the same as the Windows Service running as SYSTEM, but should be close enough)
I attempt the query:
restore database WoofPACS from disk = 'C:\Program Files\Microsoft SQL Server\MSSQL15.MSSQLSERVER\MSSQL\Backup\fulldatabase2019.11.25.16.57.24.bak'
and get the error
Cannot open backup device 'C:\Program Files\Microsoft SQL Server\MSSQL15.MSSQLSERVER\MSSQL\Backup\fulldatabase2019.11.25.16.57.24.bak'. Operating system error 2(The system cannot find the file specified.).