I'm using a SQL Express database on my development machine. Unfortunately, I had to re-install the operating system and all the software on the machine. Now I need help to restoring the database that I was using before the re-installation. I have a backup of all files on the computer from before re-installing, but how do I find and restore the database from it?
You say you have a backup, but I'm not convinced that you do. Do you have any *.BAK files on your machine?
If not, you need to locate the data file (and preferably the log file as well). Depending on how you created the database originally, the files /should/ be in the form of <database name>[_data].mdf (data file) and <database name>[_log].ldf (log file).
Once you've found the files, you can use CREATE DATABASE ... FOR ATTACH and if the log file is damaged you can use the option FOR ATTACH_REBUILD_LOG instead.
A couple of notes:
(a) if you have a backup of the database, the link Rick Liddle created will be useful. Depending on whether your new instance of SQLExpress is located in the same location, you may need to use WITH MOVE to move the data and/or log file to valid folders in order to restore your databases.
(b) depending on what happened to your old machine (e.g. did it crash and die, how was the backup obtained, etc.), the mdf and/or ldf files may not be restorable. This is what proper database backups are designed to insure against.
Are you sure you have an actual backup (.BAK)?
Create a new database.
Right click
Select Tasks
Restore
Files and FileGroups...
Select File
Related
I have been given a copy of a Marklogic v9 database backup which was taken from a Marklogic server running on linux.
I now need to restore the database from the backup dump, onto a windows 2016 server, but the MarkLogic database on the destination windows server doesnt exist.
Is it possible to somehow extract the MarkLogic database configuration from the backup dump , create a database on the destination server then restore over that database? In the backup dump I have a forests directory and all the XML/cfg/label files in the root directory of backup dump.
Or do I need a MarkLogic admin to extract the config of prod database that was backed up, then create an empty database on the destination server ( using the extracted prod database config ), then restore over that? I notice you cant restore without an existing database to restore over.
Or do I alternatively create a dummy database on my destination server of the same name as the prod database, then restore over that? The disk layout obviously will be different.
Any help appreciated.
You cannot restore a backup from a different architecture. If you need to move from Linux to Windows, I'd recommend using MLCP export/import, or maybe even copy. In any case you will need to have a target database up and running. You could export the configuration from one system, and import it in the other using our REST apis, like Configuration Management API or Management API. Our community tool ML-Gradle could be of help with that.
HTH!
I am trying to restore a database from the backup (.bak) file which is [saved] inside a ZIP file, but not been successful so far. However, I am able to restore it after extracting from the ZIP file.
This MS page says every edition of SQL Server 2008 and later can restore a compressed backup with the following restrictions.
Restrictions: The following restrictions apply to compressed backups:
Compressed and uncompressed backups cannot co-exist in a media set.
Previous versions of SQL Server cannot read compressed backups.
NTbackups cannot share a tape with compressed SQL Server backups.
I do not clearly understand the first restriction. Could someone please clarify/elaborate this?
I have done the following steps:
Taken a backup on a staging SQL Server [MyTestDB.bak]; Compressed it (by Right Click > Send To - Compressed(zipped) folder); Now, named it as MyTestDB.ZIP
FTP'd the ZIP file to local development SQL Server and trying to restore it from the ZIP file. But the database name is not available to backup.
Both SQL Server versions are exactly same.
SQL Servers Version: Microsoft SQL Server 2012 - 11.0.5058.0 (X64)-Standard Edition (64-bit)
Would the usage of term 'compressed backup' for the backup files saved inside ZIP files is correct or Is this need to be backed up in a different way so it can be called as a compressed backup?
However, if I select the .bak file after extracting it from the ZIP file it all works fine.
I am not sure where I am going wrong? I can simply extract the backup and restore it without any problem, but would like to know the cause why it is not working, as it would have been a much better solution to just back up it from the ZIP itself.
Backup compression is something different.
You specify this when you configure or start the backup and you then get a backup file that contains compressed data, as opposed to it containing uncompressed data if you don't enable compression.
SQL Server is not able to use a zip file, while the backup file is certainly compressed, it is not a "compressed backup" that this refers to.
So yes, you need to extract the backup file before restoring from it.
If you want to learn how to make compressed backups correctly, check out this page full of links to related material:
Configure Backup Compression
I have some pre-built databases that go with a base software release.
Previously we have released the MDFs and a little tool to copy/attach them, and just letting SQL Server rebuild the log file.
Is releasing the backup BAK files and modifying the tool to restore them a better approach?
Personally i like to backup and restore, but that is just personal preference.
Either method works and if you already have a tool to attach the data files, then i'd just go with what you already have.
Let us start with...yes I am new to SQL and really only a lightweight programmer. So I am assuming that I am doing something horribly wrong. I have spent days on the MS forums looking for an answer to no avail. So I am going to give as much info as possible.
Application language is VBExpress 2010 and using SQLExpress 2008. The Database contain basic tables, no stored procs, no views, no diagrams. The Application has configured diagrams where one of the tables has inner joins... Tables origninally built in SSMS, but have been altered in VBE.
Anytime I run the application, even after exiting the application, if I then go to SSMS I can see the database name but I cannot open it up (no + beside it). If I try I get an error that says:
One or more files do not match the primary file of the database. If you are attempting to attach a database retry the operation with the correct files. If this is an existing database the file may be corrupted and should be restored from a backup."
When I look at the files, I see two log files, one with _1 appended on to it. If I delete the logfiles before opening SSMS, everything opens fine. If I had already opened SSMS then I have to delete the files, reboot my computer and then I can access the database through SSMS...
I recently found that if I go into SSMS, take the database offline and then bring it back online I can get access back.
Anytime I open SSMS, I have to completely reboot my computer before VBE will reconnect the database.
The bottom line is that I cannot back up the database without either deleting the log files or doing an offline/online cycle in SSMS....
This is driving me nuts. I cannot possilby deploy the application if I cannot achieve a normal backup procedure. And I cannot seem to get any kind of answer about why this is happening.
What am I doing so WRONG?
If you are using SQL Server 2008 then, reattach the database files and it will must be stored in C:\Program Files\Microsoft SQL Server\MSSQL 10.MSSQLSERVER\MSSQL\DATA.
And recheck the database on that folder and it will take backup and restore point of Primary files of Database. Don't modify/delete the database files. If the location of log files are changed the it will shows the error. Please give your mail id I'll send a program to restore and backup of database files in winrar.
Thank you
Regards,
Naresh.
How is it possible to restore a database in Machine A (where sql server is installed) from the backup file located in Machine B.
Is it possible to avoid to copy the bak file to the machine A?
Yes it is.
Create a file share on machine B. Then restore from the file there.
Although you don't create a copy of the file 'per se' you still have to get the content of the backup file across.
You have to (read: want to) get that file on the server hosting SQL Server. Assuming that this is a large file, you don't want to restore from across the network which will be much slower. If you can't copy it because of the time involved, or the space on the SQL Server, I'd suggest an external USB drive or something.