Do I need to run a command to set them back to Restoring or do I leave
it and the log shipping will automatically sort it out?
The answer to this question is: it depends... The process that you go through to fail over to the Secondary will directly impact whether or not you need to refresh the Secondary from a full backup. A key question is whether or not you're able to connect to the Primary when bringing up the Secondary. Let's consider the process you mention above:
- Bring Secondary online.
- Point DNS at the Secondary so applications can connect.
If the Primary is still running, this means both Primary and Secondary are now in RECOVERY mode, which will end up breaking the Log Shipping process if the LSNs are advanced on both the Primary and Secondary.
Instead, to prepare the environment for failing back later you want to put the Primary databases into NORECOVERY mode before you fail over to the Secondary. The steps look like this:
- Back up the tail of the log for each database on the Primary, making sure to leave them in NORECOVERY mode.
- Apply the tail of the log for each database on the Secondary, bringing the LSNs in line with the Primary.
- Bring the Secondary online.
- Point DNS at the Secondary so applications can connect.
Then, should you then want to fail back to the Primary after it comes back online, you essentially reverse the steps:
- Back up the tail of the log for each database on the Secondary, making sure to leave them in NORECOVERY mode.
- Apply the tail of the log for each database on the Primary, bringing the LSNs back in line with the Secondary.
- Bring the Primary online.
- Point DNS at the Primary so applications can connect.
It's more involved than just the above steps, such as needing to stop the Log Shipping jobs when you fail over, enable them when you fail back, etc., but it helps with the main idea.
To make this an easier and more repeatable process, consider using this solution for a jump start. We use it regularly to test our DR procedures and ensure we can recover in a DR situation.