I'm trying to restore a db from Microsoft (AdventureWorks2012). However, when I try to restore the .bak file, it seems like SSMS doesn't recognize it and I get an error:
No backup set selected to be restored
I gave full permissions to the folder which contains the .bak file.
Steps I've taken to restore the .bak file:
Right click on DB -> Restore DB -> From device (selected the .bak file location) -> To Database (selected the DB destination)
Here is a screenshot:
That is the error message that typically coincides with trying to restore a backup from a newer version on an older version. And it looks like you have sql server 10.5 in your screen which is 2008r2. And you are trying to restore AW2012. That will never work. You can't restore a newer version to an older version.
Related
I have SQL Server 2012 (64-bit) (MSSQL11)
running on Windows 2012 R2 (64-bit) (NT 6.3)
with .NET framework 4.0.
It has a database called db_X and since this is a live production database it is always running and stopping it is not an option.
This is the only SQL Server database server that I practically have.
I want to take a backup (i.e. a full backup) of db_X (which I know how to do) and restore that backup (that .bak file) under a different name (say db_Y) in the same SQL Server database server.
I created a new database called db_Y, then right clicked db_Y then went to Tasks --> Restore --> Database...
Then I gave the path to that .bak file (as source) and tried to restore it by giving db_Y as destination (with the option - overwrite the existing database i.e. WITH REPLACE)
But this is not working. It is giving an error.
It says restore of database db_Y failed. System.Data.SqlClient.SqlError: The file C:...\db_X1.mdf cannot be overwritten. It is being used by database db_X. Microsoft.SqlServer.SmoExtended.
But I still believe that this can be done using the Management Studio. Or at least using a script. (as this is a common requirement.)
Why is it trying to restore on db_X, when I have clearly given db_Y as my destination? Isn't this a bit scary as db_X is my live database (because I might lose some data)?
How is it possible to (have a copy of an existing and running database under a different name in SQL Server or in other words) restore a backup of an existing and running database with a different name in SQL Server 2012?
I am grateful if someone could kindly explain how this can be done using the Management Studio or at least using a script.
When you are restoring the database, you need to rename the database to something other than the name of the original:
And then click the Files section and makes sure the file names are different than the original database:
I am just trying to restore a SQL Server .bak file in my DBeaver UI. But I have no idea how to do this - can someone help please?
I created a database, but when I right click on it, there are no restore options.
I do not see that option either in my version of DBeaver (6.1.3 - community). What you could do is initiate a restore with TSQL (by clicking on SQL Editor while you are connected to your database). Then in the Script area, use the below, modified for your own environment/database name.
USE [master] RESTORE DATABASE [DatabaseName] FROM
DISK = N'C:\FolderName\BackupName.bak' WITH FILE = 1, NOUNLOAD, REPLACE, STATS = 10
For full Tsql options to restore a database, see this: RESTORE Statements (Transact-SQL)
In my case the database migration was done on windows environment so there was some issue restoring backup in Ubuntu 18.04 which was fixed from below command.
backup file path: /var/opt/mssql/data/
move file path: /var/opt/mssql/data/
Restoring database backup in Ubuntu using DBeaver
RESTORE DATABASE MYDB_API FROM DISK = N'/var/opt/mssql/data/mydb.bak'
WITH MOVE 'MYDB_API' TO '/var/opt/mssql/data/mydb.mdf'
, MOVE 'MYDB_API_log' TO '/var/opt/mssql/data/mydb_log.ldf'
REPLACE
Note: if above does not work for you then remove REPLACE from above and make sure MYDB_API does not exist on SQL Server.
It looks like you are using a macOS which is a system not supported by SQL Server Management Studio (SSMS).
So I assume you need to restore SQL Server database with .bak file under macOS GUI.
There is no GUI option to retore .bak file with DBeaver.
If you want absolutely a restoration with GUI and not TSQL, an alternative on macOS is Azure Data Studio (from Microsoft) which is an open source data management tool that runs on Windows, macOS, and Linux.
You can easily restore a bak file in GUI with Azure Data Studio.
Here is the tutorial:
https://learn.microsoft.com/en-us/sql/azure-data-studio/tutorial-backup-restore-sql-server
Restore a database from a backup file (With Azure Data Studio)
Open the SERVERS sidebar (CTRL+G), right-click your server, and select Manage.
Open the Restore database dialog (click Restore on the Tasks widget).
Select Backup file in the Restore from field.
Click the ellipses (...) in the Backup file path field, and select the latest backup file for TutorialDB.
Type TutorialDB_Restored in the Target database field in the Destination section to restore the backup file to a new database.
Click Restore
To view the status of the restore operation, press CTRL+T to open
the Task History sidebar.
I am trying to restore .bak file on SQL Server 2014, but it is not working. Initially, I tried:
On SQL Server 2014, right click on Databases -> Restore Database
From Source, click on Device and chose the path to the .bak file
However, this did not work and nothing happened. When I was reading old SO posts to find a solution for this, someone had said I could use SQL command for it. So I tried the following command:
RESTORE DATABASE Student
FROM DISK = 'C:\Program Files (x86)\Microsoft SQL Server\MSSQL12.MSSQLSERVER2014\MSSQL\Backup\Student.bak'
However, this gives
Cannot open backup device ''C:\Program Files (x86)\Microsoft SQL Server\MSSQL12.MSSQLSERVER2014\MSSQL\Backup\Student.bak'. Operating system error 5 (Access is denied)
RESTORE DATABASE is terminating abnormally
When I SO'ed this error, I found some posts with the same issue. Someone said:
On SQL Server 2014, right click on Databases -> Restore Database
Click on Files
Fill the checkbox Relocate all files to folder
will fix the issue, and this answer got many up-votes. However, on my SQL Server, this checkbox is grayed out and I cannot even check/uncheck it.
I also tried a way that many had mentioned:
Open SQL Server 2014 Configuration Manager
Change Log On As of SQL Server (MSSQLSERVER2014) to LocalSystem
This also did not work.
I am at a loss what to do to fix this problem. This problem started happening after I uninstalled and reinstalled SQL Server 2014. I had an installer, but I mistakenly selected Evaluation Mode about a month ago when I first installed it, and today I got an error message saying:
Evaluation period has expired.
So I uninstalled SQL Server 2014 and reinstalled it with EXPRESS Mode this time. Upon installation I got an error and I had to change the default name from MSSQLSERVER to MSSQLSERVER2014 because I already had the folder of that name from the previous installation. So I am trying to restore the .bak file in MSSQLSERVER2014.
I'm using a backup file to restore a database to a different database. The source database is the only one in the backup file and is selected as source.
A different database is the destination.
The restore option is overwrite the existing database (with replace). The restore as files are renamed to the destination database's files.
Other than the selected database's name in the file, the source is not involved at all in the restore.
After the restore the source database immediately goes into recovery and I have to restore it to get it out.
Even though it is not being touched.
Can anyone tell me how to stop this?
The server and studio versions are below.
Very much appreciated.
SQL Server 2008 (Version 10.0.2757.0)
SQL Server Management Studio 2012 (Version 11.0.6020.0)
(I have searched for this issue but found nothing fitting this description.)
I have a .sql database which is from a different computer to ms-sql 2012 version.
When I try restoring it, it says: "no backup selected to be restored". I tried setting the permissions, tried restoring using restore tsql statement, but nothing seems to be working. Both are the same version, 2012.
restore database tables from disk='E:\tables\Tables.bak'