I have log shipping set up from server1 to server2.
on server1 transaction logs backups are taken every 15 min to a network share folder.
these transaction log backups are then copied (afte 1 hour) to server2 where they are restored.
question:
in the event that I need to bring any of these databases from standby to online, how do I find out what transaction logs need to be restored for each database?
I found these 2 good links:
Your poor man’s SQL Server log shipping-PowerShell version
Automate Restoration of Log Shipping Databases for Failover in SQL Server
this second one did not work for me:
on msdb:
SELECT destination_dir, destination_database, last_file_loaded
FROM log_shipping_plans a INNER JOIN log_shipping_plan_databases b
ON a.plan_id=b.plan_id
Best Answer
this script is to be run on
server1
and gives me the latest log backup that is availableand this script is to run on
server2
and gives me the latest transaction log backup that has been restored: