Solved

Restore a SQL .bak file on a server

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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Why is this different from all of the other step by step guides?  Because I make a living as a DBA and not as a writer and I lived through this experience. Defining the name: When I talk to people they say different names on this subject stuff l…
If you have heard of RFC822 date formats, they can be quite a challenge in SQL Server. RFC822 is an Internet standard format for email message headers, including all dates within those headers. The RFC822 protocols are available in detail at:   ht…
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…
Via a live example, show how to set up a backup for SQL Server using a Maintenance Plan and how to schedule the job into SQL Server Agent.

863 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

Need Help in Real-Time?

Connect with top rated Experts

19 Experts available now in Live!

Get 1:1 Help Now