How to restore a db using .bak without the .mdf?

  • Hi Folks,

    I have a newbie question here:

    What happens if I have a backup file (.bak), but somehow I lost the database that it belongs to?

    For example… db server catches on fire, and all data is lost, including the .mdf database file.

    Without the orginal .mdf file is the .bak any useful?

    If I cannot restore using the .bak without the original DB File…then what is the method to restore a database, assuming I’ve lost the .mdf, but kept .bak at different locations...

    Regards,

    - Joel

  • You don't need the database files to restore a database from the backup files. This why you can restore the database to a brand new server, it will create the .mdf and .ldf files (and the .ndf files if those are needed as well).

  • Yeah, as a matter fact the reason I posted the question was because I tried to restore a db. from a backup file..and I got an error message saying something like: "Wrong database name etc.." so I thought I might need the .mdf..

    I relaized now, that i had to give it a name during the backup operation if the dabase is not present..

    and this worked..

    Thanks,

    Joel

  • You can restore a database by just using .bak file / (backup file). To attach a database you need .mdf - .ldf files.

    DBDigger Microsoft Data Platform Consultancy.

  • make sure you select "Replace" option then it works fine.

  • You only need the REPLACE option on the RESTORE if the .mdf/.ldf files already exist on the server you are restoring the database.

  • You can also use the RESTORE FILELISTONLY command to see what databases exist in the .bak backup file.

    Example:

    RESTORE FILELISTONLY

    FROM DISK = 'enter file path with filename'

Viewing 7 posts - 1 through 6 (of 6 total)

You must be logged in to reply to this topic. Login to reply