Restore SQL Server database backup of one machine to another -


scenario:

  • i have database backup (abc.bak) on 1 machine
  • i copied machine path let's g:\sqldb\backup\master_copy.bak
  • i used following t-sql try , restore - errors.

t-sql used:

restore database new_db disk = 'g:\sqldb\backup\master_copy.bak'       move 'coop_test_dat' 'g:\sqldb\livedb\new_db_data.mdf',     move 'coop_test_log' 'g:\sqldb\livedb\new_db_log.ldf',     replace 

error generated:

msg 5133, level 16, state 1, line 1
directory lookup file "c:\sqldb\masterdb\master_blank.mdf" failed operating system error 3(the system cannot find path specified.).

msg 3156, level 16, state 3, line 1
file 'coop_demo' cannot restored 'c:\sqldb\masterdb\master_blank.mdf'. use move identify valid location file.

here given specified path old machine doesn't exists in new machine.

how can fix this?

what jeroen suggested was, might missing files..so see files use below command..

restore filelistonly disk ='your .bak path' file=1 

the output of above command show files backed up,then can use restore replace

so if restore file list showed below logical file names

logicalname   db_data db_data1 db_log 

now can use

restore database new_db disk = 'g:\sqldb\backup\master_copy.bak'  move 'db_data' 'g:\sqldb\livedb\new_db_data.mdf', move 'db_data1' 'g:\sqldb\livedb\new_db_data.ndf', move 'db_lof 'g:\sqldb\livedb\new_db_log.log', replace 

Comments

Popular posts from this blog

html - How to set bootstrap input responsive width? -

javascript - Highchart x and y axes data from json -

javascript - Get js console.log as python variable in QWebView pyqt -