Solved

Restore a SQL .bak file on a server

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

NAS Cloud Backup Strategies

This article explains backup scenarios when using network storage. We review the so-called “3-2-1 strategy” and summarize the methods you can use to send NAS data to the cloud

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Query Help - MSSQL - Averages 5 27
Text file into sql server 5 26
sql 2008 how to table join 2 15
T-SQL Default value in Select? 5 26
International Data Corporation (IDC) prognosticates that before the current the year gets over disbursing on IT framework products to be sent in cloud environs will be $37.1B.
This article shows gives you an overview on SQL Server 2016 row level security. You will also get to know the usages of row-level-security and how it works
Familiarize people with the process of utilizing SQL Server functions from within Microsoft Access. Microsoft Access is a very powerful client/server development tool. One of the SQL Server objects that you can interact with from within Microsoft Ac…
Familiarize people with the process of retrieving data from SQL Server using an Access pass-thru query. Microsoft Access is a very powerful client/server development tool. One of the ways that you can retrieve data from a SQL Server is by using a pa…

773 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