Today a request came in from a client to move the ldf file of a mirror database to a new SAN drive on the DR server. My immediate thought was that I would have to break the mirroring solution, recover the database and then move the files. Luckily I didn’t have to go that far – I was able to alter the database metadata while the database was still in the restoring state. For posterity (or otherwise) here are the steps I followed:
- Ensure that mirroring is fully synchronized.
- Pause mirroring on the primary server.
- On the DR server run the alter database statements:
ALTER DATABASE MODIFY FILE(NAME = [logical filename], FILENAME = N'[path]+[physical filename]');
- Stop the SQL Server service on the DR (using the SQL Server configuration manager).
- Copy the ldf and/or mdf files to the new location.
- Start the SQL Server service.
- Check the SQL Server error logs and ensure that the restart was error free.
- Resume mirroring. (It may take a few minutes for the connection to re-establish and allow mirroring to be resumed. Try refreshing the database view in the SSMS object explorer until the status shows as suspended)
- Monitor mirroring for re-synchronization and clean up the old files.