• unematt - Tuesday, November 21, 2017 11:31 AM

    Ok, I got a DB to restore and the log shipping scripts to run without giving an error! Thanks Sue!! 

    The DB in the second server shows as restoring, even after the script finishes. How can I get it back to a usable state if/when the primary server goes down?

    Matt

    You want the database to be restoring or in standby - that's how log shipping works.

    If the primary goes out for whatever reason and the secondary needs to be the database used, you would need to apply any transaction logs that haven't been applied, get a tail of the log backup from the database that was the primary (if the old primary is still available) and apply that. After you have all of the logs applied, you can restore the database using the option with recovery.

    You can keep applying logs when restoring and using the with norecovery option with any database. You can restore the last log using norecovery - some people always restore using norecovery. And the database status just shows as recovering. After everything has been restored and even if there is nothing left to restore, all you do is restore the database using with recovery and you don't even have to apply any backups. You just do: restore SomeDatabaseName with recovery

    If you were to change roles where the secondary becomes the primary and the primary becomes the secondary, that's a role switch and not too much different but you also need to execute stored procedures to switch the roles. The stored procedures are sp_change_log_shipping_primary_database and sp_change_log_shipping_secondary_database.

    These documents explain the processes for both:
    Fail Over to a Log Shipping Secondary (SQL Server)
    Change Roles Between Primary and Secondary Log Shipping Servers (SQL Server)

    Sue