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
Solved

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

Posted on 2011-03-02
8
922 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
Optimizing Cloud Backup for Low Bandwidth

With cloud storage prices going down a growing number of SMBs start to use it for backup storage. Unfortunately, business data volume rarely fits the average Internet speed. This article provides an overview of main Internet speed challenges and reveals backup best practices.

 
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 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

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

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

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…
Microsoft Active Directory, the widely used IT infrastructure, is known for its high risk of credential theft. The best way to test your Active Directory’s vulnerabilities to pass-the-ticket, pass-the-hash, privilege escalation, and malware attacks …
Email security requires an ever evolving service that stays up to date with counter-evolving threats. The Email Laundry perform Research and Development to ensure their email security service evolves faster than cyber criminals. We apply our Threat…

808 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