Solved

Restore a SQL .bak file on a server

Posted on 2013-11-29
2
792 Views
Last Modified: 2013-11-29
Hello,

We use SQLEXPRESS 2008 R2 (v 10.50.1600) on a Windows Server 2008 R2 (64bits).

We launch the following batch file on a daily basis which launch a SQL script

sqlcmd -U sa -P MyPassword -S .\SQLEXPRESS -i F:\SQL_backup\bkp_BGDATdoc_SQL.sql  >> F:\SQL_backup\SQLExpress_FullBackup.log

The scirpt bkp_BGDATdoc_SQL.sql does the following

BACKUP DATABASE [BGDATdoc_SQL] FILEGROUP = N'PRIMARY' TO  DISK = N'F:\SQL_backup\BGDATdoc_SQL.bak' WITH NOFORMAT, INIT,  NAME = N'BGDATdoc_SQL-Full Filegroup Backup', SKIP, NOREWIND, NOUNLOAD,  STATS = 10
GO
declare @backupSetId as int
select @backupSetId = position from msdb..backupset where database_name=N'BGDATdoc_SQL' and backup_set_id=(select max(backup_set_id) from msdb..backupset where database_name=N'BGDATdoc_SQL' )
if @backupSetId is null begin raiserror(N'Verify failed. Backup information for database ''BGDATdoc_SQL'' not found.', 16, 1) end
RESTORE VERIFYONLY FROM  DISK = N'F:\SQL_backup\BGDATdoc_SQL.bak' WITH  FILE = @backupSetId,  NOUNLOAD,  NOREWIND
GO

We get the following result in the following file F:\SQL_backup\SQLExpress_FullBackup.log

------------------------------------------------------------------------------
mar. 26/11/2013
20:00
------------------------------------------------------------------------------
10 percent processed.
20 percent processed.
30 percent processed.
40 percent processed.
50 percent processed.
60 percent processed.
70 percent processed.
80 percent processed.
90 percent processed.
100 percent processed.
Processed 4240 pages for database 'BGDATdoc_SQL', file 'BGDATdoc_SQL_dat' on file 1.
Processed 1 pages for database 'BGDATdoc_SQL', file 'BGDATdoc_SQL_log' on file 1.
BACKUP DATABASE...FILE=<name> successfully processed 4241 pages in 1.575 seconds (21.032 MB/sec).
Attempting to restore this backup may encounter storage space problems. Subsequent messages will provide details.
There is insufficient free space on disk volume 'F:\' to create the database. The database requires 0 additional free bytes, while only 0 bytes are available.
The backup set on file 1 is valid.
------------------------------------------------------------------------------

 So we get the backup file

F:\SQL_backup\BGDATdoc_SQL.bak

We would like to restore this file with an other name BGDATdoc_SQL_Restore on the same SQLEXPRESS 2008 R2 (v 10.50.1600) using SQL Server Management Studio 2008 R2. It is a test to check our backup is recoverable.

AND IT DOES NOT WORK

We do the following in SSMS
- right click on 'Database'
- restore database
- in ToDatabase we put the name BGDATdoc_SQL_Restore
- in FromDevice we click '...' to select the .bak file
- we backup media 'File' then we click Add
- at that point we get the message 'F:\Microsoft SQL server\MSSQL10_50.SQLEXPRESS\MSSQL\Backup' cannot access the specified path or file on the server ... verify privilege ... > we click OK
- but we are able to select de .bak file that we copied on an other accessible disk E:\DATABASE\BGDATdoc_SQL.bak
- we click on 'contents' and we can see the result Media 1, Family 1, Family Count 1, Name: BGDATdoc_SQL-Full Filegroup Backup, Type: File, Component: Full ...
- we click OK and go back to the restore windows
- there we click OK and we receive the message 'You must select a restore ressource'
- In fact the result we get when clicking 'Contents' when selecting the file does not appear in the windows 'Select the backup sets to restore'.

Are we missing something?

Thanks for the help

Regards
0
Comment
Question by:CAMTEC_SPRL
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
2 Comments
 

Accepted Solution

by:
CAMTEC_SPRL earned 0 total points
ID: 39685146
OK I found.
Thanks 'god'

here is how to

1/ create a script to list files

RESTORE FILELISTONLY FROM DISK = 'C:\Users\Public\Documents\BGDATdoc_SQL.bak' WITH FILE = 1
GO


I get 2 logical names that I used for script 2
BGDATdoc_SQL_dat
BGDATdoc_SQL_log


2/ restore de DB with a second script

RESTORE DATABASE BGDATdoc_SQL FROM disk = 'C:\Users\Public\Documents\BGDATdoc_SQL.bak'
WITH
   MOVE 'BGDATdoc_SQL_dat' TO 'C:\Program Files\Microsoft SQL Server\MSSQL.1\MSSQL\Data\BGDATdoc_SQL.mdf',
   MOVE 'BGDATdoc_SQL_log' TO 'C:\Program Files\Microsoft SQL Server\MSSQL.1\MSSQL\Data\BGDATdoc_SQL.ldf'
GO
0
 

Author Closing Comment

by:CAMTEC_SPRL
ID: 39685149
I found it myself ;)
but could help somebody
0

Featured Post

[Webinar] How Hackers Steal Your Credentials

Do You Know How Hackers Steal Your Credentials? Join us and Skyport Systems to learn how hackers steal your credentials and why Active Directory must be secure to stop them. Thursday, July 13, 2017 10:00 A.M. PDT

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Load balancing is the method of dividing the total amount of work performed by one computer between two or more computers. Its aim is to get more work done in the same amount of time, ensuring that all the users get served faster.
I have a large data set and a SSIS package. How can I load this file in multi threading?
Via a live example, show how to setup several different housekeeping processes for a SQL Server.
Viewers will learn how the fundamental information of how to create a table.

628 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question