Click here to monitor SSC
SQLServerCentral is supported by Redgate
 
Log in  ::  Register  ::  Not logged in
 
 
 


What can I do to an offline database?


What can I do to an offline database?

Author
Message
jasona.work
jasona.work
SSCommitted
SSCommitted (1.9K reputation)SSCommitted (1.9K reputation)SSCommitted (1.9K reputation)SSCommitted (1.9K reputation)SSCommitted (1.9K reputation)SSCommitted (1.9K reputation)SSCommitted (1.9K reputation)SSCommitted (1.9K reputation)

Group: General Forum Members
Points: 1877 Visits: 10900
I am in the process of migrating DBs from an old server to a new server. Currently, what I've been doing is:
1. Take a full backup
2. Set the old DB offline using
ALTER DATABASE [Whatever] SET OFFLINE WITH ROLLBACK IMMEDIATE


3. Restore the backup over-top the "test" restore on the new server.

My questions are:
1. Can I backup a DB that is in an offline state? I'm inclined to think no.
2. Can I restore over-top a DB that is in an offline state (using WITH REPLACE)?

Although, seeing as no one uses the "test" restore on the new server, except the Dev to verify they can get to it, it's not a big deal if I can or can't restore over-top it, as I can leave it online for the restore...

Thanks,
Jason
Lowell
Lowell
SSChampion
SSChampion (14K reputation)SSChampion (14K reputation)SSChampion (14K reputation)SSChampion (14K reputation)SSChampion (14K reputation)SSChampion (14K reputation)SSChampion (14K reputation)SSChampion (14K reputation)

Group: General Forum Members
Points: 14942 Visits: 38932
Jason both your suspicions are correct:
1 you cannot backup a database that is set offline;
you simply get this error:

Msg 942, Level 14, State 4, Line 2
Database 'MyDatabase' cannot be opened because it is offline.
Msg 3013, Level 16, State 1, Line 2
BACKUP DATABASE is terminating abnormally.

.
2. yes,you can restore over-top a DB that is in an offline,WITH REPLACE.

The advantage when it's offline, is there's no way for a fast-connecting application or user to reconnect to the database when you are trying to do a restore process.

setting a database to single_user or restricted_user still leaves possible avenues for connecting to the database, which can interfere with a restoration process, especially if it was scripted and assumed to be able to complete without any errors.

Lowell

--
help us help you! If you post a question, make sure you include a CREATE TABLE... statement and INSERT INTO... statement into that table to give the volunteers here representative data. with your description of the problem, we can provide a tested, verifiable solution to your question! asking the question the right way gets you a tested answer the fastest way possible!

Perry Whittle
Perry Whittle
SSCrazy Eights
SSCrazy Eights (8.8K reputation)SSCrazy Eights (8.8K reputation)SSCrazy Eights (8.8K reputation)SSCrazy Eights (8.8K reputation)SSCrazy Eights (8.8K reputation)SSCrazy Eights (8.8K reputation)SSCrazy Eights (8.8K reputation)SSCrazy Eights (8.8K reputation)

Group: General Forum Members
Points: 8780 Visits: 16554
jasona.work (7/8/2013)
1. Can I backup a DB that is in an offline state? I'm inclined to think no.

No, you cannot backup an offline database, however you can copy or move or even delete the raw database files (mdf and ldf).



jasona.work (7/8/2013)
2. Can I restore over-top a DB that is in an offline state (using WITH REPLACE)?

If a database is offline you can restore over the top of it no problem.

-----------------------------------------------------------------------------------------------------------

"Ya can't make an omelette without breaking just a few eggs" ;-)
jasona.work
jasona.work
SSCommitted
SSCommitted (1.9K reputation)SSCommitted (1.9K reputation)SSCommitted (1.9K reputation)SSCommitted (1.9K reputation)SSCommitted (1.9K reputation)SSCommitted (1.9K reputation)SSCommitted (1.9K reputation)SSCommitted (1.9K reputation)

Group: General Forum Members
Points: 1877 Visits: 10900
That's what I thought. I figured setting it to offline for the restore would prevent connections, having seen several postings here from people trying to do maintenance in single-user and getting beat to the connection by an application or other user...

Once more, thanks,
Jason
Perry Whittle
Perry Whittle
SSCrazy Eights
SSCrazy Eights (8.8K reputation)SSCrazy Eights (8.8K reputation)SSCrazy Eights (8.8K reputation)SSCrazy Eights (8.8K reputation)SSCrazy Eights (8.8K reputation)SSCrazy Eights (8.8K reputation)SSCrazy Eights (8.8K reputation)SSCrazy Eights (8.8K reputation)

Group: General Forum Members
Points: 8780 Visits: 16554
jasona.work (7/8/2013)
seen several postings here from people trying to do maintenance in single-user and getting beat to the connection by an application or other user..

The trick is to set the database single user and then in the same query session restore the database that waxy you will hold the single user connection ;-)

-----------------------------------------------------------------------------------------------------------

"Ya can't make an omelette without breaking just a few eggs" ;-)
Go


Permissions

You can't post new topics.
You can't post topic replies.
You can't post new polls.
You can't post replies to polls.
You can't edit your own topics.
You can't delete your own topics.
You can't edit other topics.
You can't delete other topics.
You can't edit your own posts.
You can't edit other posts.
You can't delete your own posts.
You can't delete other posts.
You can't post events.
You can't edit your own events.
You can't edit other events.
You can't delete your own events.
You can't delete other events.
You can't send private messages.
You can't send emails.
You can read topics.
You can't vote in polls.
You can't upload attachments.
You can download attachments.
You can't post HTML code.
You can't edit HTML code.
You can't post IFCode.
You can't post JavaScript.
You can post emoticons.
You can't post or upload images.

Select a forum

































































































































































SQLServerCentral


Search