dbTalk Databases Forums  

XP: Restore database fails

microsoft.public.sqlserver.setup microsoft.public.sqlserver.setup


Discuss XP: Restore database fails in the microsoft.public.sqlserver.setup forum.



Reply
 
Thread Tools Display Modes
  #1  
Old   
Bernd Maierhofer
 
Posts: n/a

Default XP: Restore database fails - 12-02-2009 , 02:36 AM






This is a setup issue of our application. The app gets installed into the
ProgramFiles-Dir and creates a subdir database there.
Structure:
programfiles\appdir\database

To the database-dir a backup is successfully copied and the onstaller tries
to do a restore, with the database files located in this database-dir.
Usually this is no problem, but on XP (maybe Vista and Win7 too) machines,
the restore fails. Why?

SQL2005 Express is used. The installer is INNO, the restore is issued using
DMO.

The same succeeds if the app is installed in the root folder, so there must
be a problem with rights for creating the database files in the users
directory?

TIA
Bernd

Reply With Quote
  #2  
Old   
Erland Sommarskog
 
Posts: n/a

Default Re: XP: Restore database fails - 12-02-2009 , 04:50 PM






Bernd Maierhofer (bernd.maierhofer (AT) dato (DOT) at) writes:
Quote:
To the database-dir a backup is successfully copied and the onstaller
tries to do a restore, with the database files located in this
database-dir. Usually this is no problem, but on XP (maybe Vista and
Win7 too) machines, the restore fails. Why?
What is the error message?

Quote:
SQL2005 Express is used. The installer is INNO, the restore is issued
using DMO.
Which is the service account for SQL Server?

Quote:
The same succeeds if the app is installed in the root folder, so there
must be a problem with rights for creating the database files in the
users directory?
User's directory? I understood that you put the database in to
ProgramFilesDir?




--
Erland Sommarskog, SQL Server MVP, esquel (AT) sommarskog (DOT) se

Links for SQL Server Books Online:
SQL 2008: http://msdn.microsoft.com/en-us/sqlserver/cc514207.aspx
SQL 2005: http://msdn.microsoft.com/en-us/sqlserver/bb895970.aspx
SQL 2000: http://www.microsoft.com/sql/prodinf...ons/books.mspx

Reply With Quote
  #3  
Old   
Bernd Maierhofer
 
Posts: n/a

Default Re: XP: Restore database fails - 12-03-2009 , 03:06 AM



Quote:
What is the error message?
IŽll check that in detail.

Quote:
SQL2005 Express is used. The installer is INNO, the restore is issued
using DMO.

Which is the service account for SQL Server?
I do a fresh install of 2005 with admin rights, changing nothing. The code I
use this (without error handling):

SQLServer := CreateOleObject('SQLDMO.SQLServer');
SQLServer.LoginSecure := True;
SQLServer.Connect(SQLServerName);
DB := CreateOleObject('SQLDMO.Database');
DB := SQLServer.Databases('master');
s := ExpandConstant('{app}') + '\Database\';
sSql := 'RESTORE DATABASE [nuts] FROM ' + 'DISK = N''' +
s + 'nuts_deploy.bak'' WITH FILE = 1, ' +
'MOVE N''nuts_data'' TO N''' + s + 'nuts.mdf'', ' +
'MOVE N''nuts_log'' TO N''' + s + 'nuts.ldf'', NOUNLOAD,
REPLACE, STATS = 10 ';
DB.ExecuteImmediate(ssql);

So I thought, the service account of SQLServer has access rights to the dir
where the user is allowed to copy files to.

Quote:
The same succeeds if the app is installed in the root folder, so there
must be a problem with rights for creating the database files in the
users directory?

User's directory? I understood that you put the database in to
ProgramFilesDir?
Yes.
Here it fails: \<ProgramFilesDir>\<appdir>\DataBase
Here it works: \<appdir>\DataBase

TIA Bernd

Reply With Quote
  #4  
Old   
Erland Sommarskog
 
Posts: n/a

Default Re: XP: Restore database fails - 12-03-2009 , 04:43 PM



Bernd Maierhofer (bernd.maierhofer (AT) dato (DOT) at) writes:
Quote:
What is the error message?
IŽll check that in detail.
I'm looking forward to seeing it.

Quote:
SQL2005 Express is used. The installer is INNO, the restore is issued
using DMO.

Which is the service account for SQL Server?
I do a fresh install of 2005 with admin rights, changing nothing.
Does this mean that you use LocalSystem? (I'm sorry, but it may help
if you answers the questions being asked.)

What do you mean "with admin rights". That you are logged into Windows
with administrator rights or something else?

Quote:
Yes.
Here it fails: \<ProgramFilesDir>\<appdir>\DataBase
Here it works: \<appdir>\DataBase
I would have been less surprised if this had been issue on Vista, since
Vista do really want you to put application data in Program Files as
I understand, if I want to copy files into Program Files, I get a UAC
alert.

But maybe there are similar restrictions on XP.

Have you compared the Windows permissions on the two directories?

--
Erland Sommarskog, SQL Server MVP, esquel (AT) sommarskog (DOT) se

Links for SQL Server Books Online:
SQL 2008: http://msdn.microsoft.com/en-us/sqlserver/cc514207.aspx
SQL 2005: http://msdn.microsoft.com/en-us/sqlserver/bb895970.aspx
SQL 2000: http://www.microsoft.com/sql/prodinf...ons/books.mspx

Reply With Quote
  #5  
Old   
Bernd Maierhofer
 
Posts: n/a

Default Re: XP: Restore database fails - 12-04-2009 , 01:50 AM



Quote:
Which is the service account for SQL Server?
I do a fresh install of 2005 with admin rights, changing nothing.

Does this mean that you use LocalSystem? (I'm sorry, but it may help
if you answers the questions being asked.)
I do not know what the srevice account is - what I know is, that I used the
default values. I do a silent install using these settings:

start /wait setup.exe /qb /settings c:\all.ini

[Options]
ADDLOCAL=SQL_Engine,Client_Components,Connectivity
INSTANCENAME=MSSQLSERVER
SQLBROWSERAUTOSTART=1
SQLAUTOSTART=1
AGTAUTOSTART=1
ASAUTOSTART=1
RSAUTOSTART=1
SECURITYMODE=SQL
SAPWD=...
DISABLENETWORKPROTOCOLS=0
ADDUSERASADMIN=1

Quote:
What do you mean "with admin rights". That you are logged into Windows
with administrator rights or something else?
The user installtin has admin rights and the user installing is added as
admin to the SQLServer.

Quote:
Here it fails: \<ProgramFilesDir>\<appdir>\DataBase
Here it works: \<appdir>\DataBase

I would have been less surprised if this had been issue on Vista, since
Vista do really want you to put application data in Program Files as
I understand, if I want to copy files into Program Files, I get a UAC
alert.
Copying files was not the issue. Restoring the database was. LocalSystem
must not be forbidden to write to \<ProgramFilesDir>\<appdir>\DataBase, must
it?

TIA Bernd

Reply With Quote
  #6  
Old   
Erland Sommarskog
 
Posts: n/a

Default Re: XP: Restore database fails - 12-04-2009 , 04:36 PM



Bernd Maierhofer (bernd.maierhofer (AT) dato (DOT) at) writes:
Quote:
I do not know what the srevice account is - what I know is, that I used
the default values.
That may be Local System for SQL 2005, but I think you should verify
it.

Quote:
Copying files was not the issue. Restoring the database was. LocalSystem
must not be forbidden to write to \<ProgramFilesDir>\<appdir>\DataBase,
must it?
I would not really expect so. Then again, I still have not seen the
error message.

And, oh, if the error is "Access is denied", this could also indicate the
files are there already, but open by another process.


--
Erland Sommarskog, SQL Server MVP, esquel (AT) sommarskog (DOT) se

Links for SQL Server Books Online:
SQL 2008: http://msdn.microsoft.com/en-us/sqlserver/cc514207.aspx
SQL 2005: http://msdn.microsoft.com/en-us/sqlserver/bb895970.aspx
SQL 2000: http://www.microsoft.com/sql/prodinf...ons/books.mspx

Reply With Quote
Reply




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.3
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.