Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

Restore backup of database (.bak) using Sql Server 2008

Posted on 2011-03-02
8
Medium Priority
?
946 Views
Last Modified: 2012-05-11
Hello experts,

Let me know what are the steps I need to follow to restore bak and trn files.
I have backup of an app DB (SQL 2008) of last night  and I need to restore them in a new SQL 2008 box that I have built.

Please advise.

Thanks and Regards,
0
Comment
Question by:goprasad
[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
8 Comments
 
LVL 10

Expert Comment

by:himanshut
ID: 35023072
0
 
LVL 27

Expert Comment

by:Chris Luttrell
ID: 35023483
On a new (different) box the easiest way is with Management Studio, just right click on Databases and chose Restore, type in a Name for your database (can be the same since new instance) and then select the From Device option and browse to where your .bak is located.  The new database files will be put in the default location defined for the instance or you can modify them on Options screen.  Then click OK.
This will NOT create Logins or map users in the database to existing Logins, you will have to take care of that.
HTH,
Chris
0
 

Author Comment

by:goprasad
ID: 35023854
Restored using SMSS using norecovery/replace, norecovery and then recovery option. But what I am find is that when I executed a query against the table the records that should have beem there for today is not showing up, even though the last transacton log back up that was restored was taken this morning.
Any thoughts?? why this inconsitency.
Plase advise.
0
Get your Disaster Recovery as a Service basics

Disaster Recovery as a Service is one go-to solution that revolutionizes DR planning. Implementing DRaaS could be an efficient process, easily accessible to non-DR experts. Learn about monitoring, testing, executing failovers and failbacks to ensure a "healthy" DR environment.

 
LVL 13

Expert Comment

by:geek_vj
ID: 35024407
If the data you are checking is present before the T-log backup on the source server, then this should have been present after the restoration.

However, if you are trying to view the data after the time where the T-log backup was taken, then you have to take a fresh T-log backup and restore it on the destination server.
0
 
LVL 2

Accepted Solution

by:
Umesh_Madap earned 1000 total points
ID: 35026282
you can customize the below code as per your requirement
 
if you have last night backup then restore the last night full backup


RESTORE DATABASE Databasename

FROM DISK = 'D: \BackupFiles\TestDatabaseFullBackup.bak'(-- give the path of the full backup location)

WITH

MOVE 'PreviousDatabase' TO 'D:\DataFiles \TestDatabase.mdf',

MOVE 'PreviousDatabase_log' TO 'D:\DataFiles \TestDatabase_Log.ldf',

NORECOVERY


once the full backup is restoed you can restore the log backup


RESTORE DATABASE Databasename

FROM DISK = 'D: \BackupFiles\tlog_backup.trn'(-- give the path of the t-log backup location)

WITH

MOVE 'PreviousDatabase' TO 'D:\DataFiles \TestDatabase.mdf',

MOVE 'PreviousDatabase_log' TO 'D:\DataFiles \TestDatabase_Log.ldf',

RECOVERY

0
 

Author Comment

by:goprasad
ID: 35162970
Sorry to get back this late, what does the move command does? Please advise.
0
 
LVL 27

Assisted Solution

by:Chris Luttrell
Chris Luttrell earned 1000 total points
ID: 35920032
The move command is to MOVE 'logical_file_name_in_backup' TO 'operating_system_file_name'
this is because if you just restore the database on the same machine but want a copy, the backup will be associated with the active os filename and you will have to move the association to a different set of files.
0
 

Author Comment

by:goprasad
ID: 36031917
I had to do it using SSMS tasks restore.
- I had copy of full backup file .bak file and then subsequent trn files (taken every 2 hours).
I was hoping to get a SQL query to perform the above operation:
that is Restore Full backup with NoRecovery
and then trn log restore using NoRecovery and for the last trn log use Recovery.
0

Featured Post

Get your Conversational Ransomware Defense e‑book

This e-book gives you an insight into the ransomware threat and reviews the fundamentals of top-notch ransomware preparedness and recovery. To help you protect yourself and your organization. The initial infection may be inevitable, so the best protection is to be fully prepared.

Question has a verified solution.

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

INTRODUCTION: While tying your database objects into builds and your enterprise source control system takes a third-party product (like Visual Studio Database Edition or Red-Gate's SQL Source Control), you can achieve some protection using a sing…
In this article I will describe the Detach & Attach 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.
Video by: ITPro.TV
In this episode Don builds upon the troubleshooting techniques by demonstrating how to properly monitor a vSphere deployment to detect problems before they occur. He begins the show using tools found within the vSphere suite as ends the show demonst…
How to fix incompatible JVM issue while installing Eclipse While installing Eclipse in windows, got one error like above and unable to proceed with the installation. This video describes how to successfully install Eclipse. How to solve incompa…

604 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