Click here to monitor SSC
SQLServerCentral is supported by Red Gate Software Ltd.
 
Log in  ::  Register  ::  Not logged in
 
 
 
        
Home       Members    Calendar    Who's On


Add to briefcase

What can I do to an offline database? Expand / Collapse
Author
Message
Posted Monday, July 8, 2013 8:39 AM


Right there with Babe

Right there with BabeRight there with BabeRight there with BabeRight there with BabeRight there with BabeRight there with BabeRight there with BabeRight there with Babe

Group: General Forum Members
Last Login: Today @ 9:14 AM
Points: 737, Visits: 5,459
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
Post #1471224
Posted Monday, July 8, 2013 8:52 AM


SSChampion

SSChampionSSChampionSSChampionSSChampionSSChampionSSChampionSSChampionSSChampionSSChampionSSChampion

Group: General Forum Members
Last Login: Today @ 10:17 AM
Points: 12,927, Visits: 32,327
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

--There is no spoon, and there's no default ORDER BY in sql server either.
Actually, Common Sense is so rare, it should be considered a Superpower. --my son
Post #1471232
Posted Monday, July 8, 2013 8:53 AM


SSCertifiable

SSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiable

Group: General Forum Members
Last Login: Today @ 10:12 AM
Points: 6,634, Visits: 14,212
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"
Post #1471234
Posted Monday, July 8, 2013 8:56 AM


Right there with Babe

Right there with BabeRight there with BabeRight there with BabeRight there with BabeRight there with BabeRight there with BabeRight there with BabeRight there with Babe

Group: General Forum Members
Last Login: Today @ 9:14 AM
Points: 737, Visits: 5,459
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
Post #1471238
Posted Monday, July 8, 2013 11:09 PM


SSCertifiable

SSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiable

Group: General Forum Members
Last Login: Today @ 10:12 AM
Points: 6,634, Visits: 14,212
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"
Post #1471440
« Prev Topic | Next Topic »

Add to briefcase

Permissions Expand / Collapse