Solved

Restore a SQL .bak file on a server

Posted on 2013-11-29
2
779 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

Comparison of Amazon Drive, Google Drive, OneDrive

What is Best for Backup: Amazon Drive, Google Drive or MS OneDrive? In this free whitepaper we look at their performance, pricing, and platform availability to help you decide which cloud drive is right for your situation. Download and read the results of our testing for free!

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.
For both online and offline retail, the cross-channel business is the most recent pattern in the B2C trade space.
Viewers will learn how to use the SELECT statement in SQL and will be exposed to the many uses the SELECT statement has.
Viewers will learn how to use the UPDATE and DELETE statements to change or remove existing data from their tables. Make a table: Update a specific column given a specific row using the UPDATE statement: Remove a set of values using the DELETE s…

710 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