Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
?
Solved

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

Posted on 2011-03-02
8
Medium Priority
?
956 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
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
Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

 
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

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

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…
Data architecture is an important aspect in Software as a Service (SaaS) delivery model. This article is a study on the database of a single-tenant application that could be extended to support multiple tenants. The application is web-based develope…
this video summaries big data hadoop online training demo (http://onlineitguru.com/big-data-hadoop-online-training-placement.html) , and covers basics in big data hadoop .
Screencast - Getting to Know the Pipeline

564 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