Moving Mirror mdf and ldf files to another drive

  • I'm currently running SQL Server 2008 R2 Enterprise with 3 servers in an active / passive / witness high availability mirror.

    As a part of planned maintenance, I've added new storage space to my mirror server. I now need to move the files to those new hard drives. Note that the primary database server will be untouched, this maintenance is only needed for the mirror server.

    At first, I had thought I could remove the mirroring, detach the mirror database, and re-attach it in the new location. However, as the mirror database is still in NORECOVERY, detach isn't available.

    If I restore the mirror WITH RECOVERY, it starts a new recovery fork and I will not be able to restart mirroring.

    I could fail the database over to the mirror, detach / reattach / restart mirroring but this will take the database offline, which I need to avoid.

    I could also do a FULL restore from backup to the mirror database, but it is quite large and this will take quite some time. I was hoping for an faster option.

    Can anyone point me in the right direction?

  • Here's an idea from the SQLCAT team. I assume it would work with data files as well. I would test this thoroughly in a test environment first.

    http://sqlcat.com/sqlcat/b/msdnmirror/archive/2010/04/05/moving-the-transaction-log-file-of-the-mirror-database.aspx

  • Thank you very very very much for that article.

    I'll be testing that on my dev server and if it goes we'll I'll run it on the real one tonight.

  • Just to update, that worked perfectly. And to reiterate, here's what I did:

    1. Connect to the Mirror DB Server, open SSMS

    2. Execute this script to find the file names:

    USE master

    SELECT name, physical_name

    FROM sys.master_files

    WHERE database_id = DB_ID('<dbname>');

    3. Execute this script on the Mirror DB

    ALTER DATABASE <dbname> MODIFY FILE (NAME = <file>, FILENAME = '<newpath>')

    I get a notification:

    The file "<file>" has been modified in the system catalog. The new path will be used the next time the database is started.

    4. Stop the Mirror Server services.

    5. Copy the files to the new locations.

    6. Start the Mirror Server services.

    7. Wait for everything to sync up again.

    8. Delete the old files.

Viewing 4 posts - 1 through 3 (of 3 total)

You must be logged in to reply to this topic. Login to reply