Solved

Restore a SQL .bak file on a server

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

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

Introduction SQL Server Integration Services can read XML files, that’s known by every BI developer.  (If you didn’t, don’t worry, I’m aiming this article at newcomers as well.) But how far can you go?  When does the XML Source component become …
In this article I will describe the Copy Database Wizard method as one possible migration process and I will add the extra tasks needed for an upgrade when and where is applied so it will cover all.
This video shows how to set up a shell script to accept a positional parameter when called, pass that to a SQL script, accept the output from the statement back and then manipulate it in the Shell.
Using examples as well as descriptions, and references to Books Online, show the different Recovery Models available in SQL Server and explain, as well as show how full, differential and transaction log backups are performed

762 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

18 Experts available now in Live!

Get 1:1 Help Now