Solved

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

Posted on 2011-03-02
8
878 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 26

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
 
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
What Is Threat Intelligence?

Threat intelligence is often discussed, but rarely understood. Starting with a precise definition, along with clear business goals, is essential.

 
LVL 2

Accepted Solution

by:
Umesh_Madap earned 250 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 26

Assisted Solution

by:Chris Luttrell
Chris Luttrell earned 250 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

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

SQL Server engine let you use a Windows account or a SQL Server account to connect to a SQL Server instance. This can be configured immediatly during the SQL Server installation or after in the Server Authentication section in the Server properties …
Use this article to create a batch file to backup a Microsoft SQL Server database to a Windows folder.  The folder can be on the local hard drive or on a network share.  This batch file will query the SQL server to get the current date & time and wi…
This video gives you a great overview about bandwidth monitoring with SNMP and WMI with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're looking for how to monitor bandwidth using netflow or packet s…
This demo shows you how to set up the containerized NetScaler CPX with NetScaler Management and Analytics System in a non-routable Mesos/Marathon environment for use with Micro-Services applications.

708 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

15 Experts available now in Live!

Get 1:1 Help Now