I have two SQL Server 2008 R2 servers one for PROD and the other for DR. I am trying to add log shipping for a database called School.
Steps so far
Back up School database
Restore with database using the UI or using the following SQL statement i.e.
Restore database "School"
From disk ='t:\Data\School.bak'
with NoRecovery
The result is database is stuck in Restoring
If I restore the database with
Restore database "School"
From disk ='t:\Data\School.bak'
With recovery
The database restore completes but the log shipping fails.
I have deleted the database and recreated it again using
Restore database "School"
From disk ='t:\Data\School.bak'
With **NoRecovery**
but it is still stuck in Restoring state.
Is there a way that I can restore the database without having the database been stuck in the restoring state.
This seems like expected behavior to me. Am I misreading something?
After you've restored the database and any differential or required transaction log backups with the NORECOVERY option, you need to tell SQL Server you're done restoring files. The NORECOVERY option is specifically there to let you restore multiple files.
You should just need to run:
RESTORE DATABASE [School] WITH RECOVERY;
That will tell SQL Server you're done, and it will complete the restoration and it will no longer show up as restoring.
I have deleted the database and recreated it again using Restore database "School" from disk ='t:\Data\School.bak' with NoRecovery
you have to use below command as well,if you dont have any further logs
restore database databasename with recovery
some more info:
Restore with database using the UI or using the following SQL statement i.e.
next time try to issue restore statement using tsql,so that you can know status
restore database databasename from disk="path"
with stats=5
now if you want to know indepth details on where it is and what it is doing,you can use a trace flag like below
dbcc traceon(3004,3605,-1)
GO
restore database databasename from disk="path"
with stats=5
this logs output to errorlog like below
2008-01-23 08:59:56.26 spid52 RestoreDatabase: Database dbPerf_MAIN
2008-01-23 08:59:56.26 spid52 Opening backup set
2008-01-23 08:59:56.31 spid52 Restore: Configuration section loaded2008-01-23 08:59:56.31 spid52 Restore: Backup set is open
2008-01-23 08:59:56.31 spid52 Restore: Planning begins
2008-01-23 08:59:56.32 spid52 Halting FullText crawls on database dbPerf_MAIN
2008-01-23 08:59:56.32 spid52 Dismounting FullText catalogs
2008-01-23 08:59:56.32 spid52 X-locking database: dbPerf_MAIN
2008-01-23 08:59:56.32 spid52 Restore: Planning complete
2008-01-23 08:59:56.32 spid52 Restore: BeginRestore (offline) on dbPerf_MAIN
2008-01-23 08:59:56.40 spid52 Restore: PreparingContainers
2008-01-23 08:59:56.43 spid52 Restore: Containers are ready
For your current problem, you can look at event log as it will log current phase
Is there a way that I can restore the database without having the database been stuck in the restoring state.
you will have to get the spid of the backup and see the wait type and troubleshoot accordingly
select * from sys.dm_Exec_requests where sessionid=backupspid
Related
I am trying to backup an Oracle 19c Database using RMAN but I seem to be running into a few hiccups. What I did first was create test tables and users in the database before backup. Within RMAN I then ran
RMAN> BACKUP DATABASE PLUS ARCHIVELOG;
With the database backed up I then dropped the test tables and users I created and starting restoring the database
RMAN> restore controlfile from 'LOCATIN OF CONTROLFILE';
RMAN> ALTER DATABASE MOUNT;
RMAN> RESTORE DATABASE;
RMAN> RECOVER DATABASE;
RMAN> ALTER DATABASE OPEN RESETLOGS;
When I then connected to the database, it is missing all the tables and users I deleted. I'm not sure whether if I needed to update my datafiles or there is a step that I am overlooking. Thank you
You have to use
Set until SCn
and provide a SCn before you are dropping the tables and and tablespaces.
You can also create a restore point before dropping tables and use rman command to restore database to restore point 'rspname'
This is impossible! Firstly, rman run with "PLUS ARCHIVELOG" so your database is currently in archivelog mode. Secondly, you restore controlfile & database then perform "COMPLETE" recovery so at the time of complete - your test tables and users must be there.
If you would have followed the steps them you must see the tables. To avoid confusion use set until time or SCN or Time
SET UNTIL SCN <scn after object creation>;
SET UNTIL SEQUENCE <seq no after table creation>;
set until time <time after table creation>;
Also pls verify did you connect to right database
Here is the example
RMAN> restore controlfile from 'LOCATIN OF CONTROLFILE';
RMAN> ALTER DATABASE MOUNT;
RMAN>RUN
{allocate channel c1 device type disk;
allocate channel c2 device type disk;
set until time '2020-03-19:15:30:00';
restore database;
recover database;
ALTER DATABASE OPEN RESETLOGS;
}
This is possibly a stupid question.
I have a "flash recovery area", with a BACKUPSET and a AUTOBACKUP folders containing .bkp files.
The rman documentation says that I have to connect to the "target" database, which should be "the database to be restored".Well, obviously, this database doesn't exist - that's why I want to restore it! I only have the backup files.So why do I have to connect to it in order to get rman to restore the database?
Do I have to create a new database, connect rman to it as target, and then restore to it?
Yes, you have to create some database instance.
I am trying to restore db from my db backup file when i select and add the db .bak file
I have seen that error "No back upset selected to be restored"
I also tried from script to restore it but failed.
kindly tell me some effective way to do that??
I have already tried this but failed
RESTORE DATABASE <Your Database>
FROM DISK='<the path to your backup file>\<Your Database>.bak'
Try RESTORE HEADERONLY to see if there are several backup sets in your bak file
RESTORE HEADERONLY
FROM DISK='<the path to your backup file>\<Your Database>.bak'
http://msdn.microsoft.com/en-us/library/ms178536.aspx
and if there are several sets, choose the one you want :
RESTORE DATABASE <Your Database>
FROM DISK='<the path to your backup file>\<Your Database>.bak'
WITH FILE = <you set number>;
i am using SQL server express 2005 as an backend. I created a backup file programmatically.If i use same server , then it restore the data successfuly. however if we try to restore on different server, then it fails. and throw following message
"The Backup set Holds a backup of a database other than the existing 'DatabaseName' database. RESTORE DATABASE is terminating abnormally."
On both server, Sql server instance name and database name is same.
Please suggest how can i resolve this error
You need to RESTORE from files (which are contained in the backup set) rather than the backup set directly. The bottom example is to copy a database, but the idea is the same.:
BACKUP DATABASE AdventureWorks
TO AdventureWorksBackups ;
RESTORE FILELISTONLY
FROM AdventureWorksBackups ;
RESTORE DATABASE TestDB
FROM AdventureWorksBackups
WITH MOVE 'AdventureWorks_Data' TO 'C:\MySQLServer\testdb.mdf',
MOVE 'AdventureWorks_Log' TO 'C:\MySQLServer\testdb.ldf';
GO
We have a warm sql backup. full backup nightly, txn logs shipped every so often during the day and restored. I need to move the data files to another disk. These DB's are in a "warm backup" state (such that I can't unmark them as read-only - "Error 5063: Database '<dbname>' is in warm standby. A warm-standby database is read-only.
") and am worried about detaching and re-attaching.
How do we obtain the "warm backup" status after detach/attach operations are complete?
The only solution I know is to create a complete backup of your active database and restore this backup to a copy of the database in a 'warm backup' state. First create a backup from the active db:
backup database activedb to disk='somefile'
Then restore the backup on another sql server. If needed you can use the WITH REPLACE option to change the default storage directory
restore database warmbackup from disk='somefile'
with norecovery, replace ....
Now you can create backups of the logs and restore them to the warmbackup with the restore log statement.
It looks like you didn't complete the restore task , just do the restore task only for the TRANSACTOINAL LOG .Then it will be fine immediately when you finish that.