How to Move an Exchange Server 2013 Database to a New Location

When you install a new Exchange Server 2013 Mailbox server a database is automatically created on the server as well.

The database is located in the \Mailbox folder of the Exchange installation path, which by default is the C:\ drive therefore a mailbox database will be placed in a path such as:

C:\Program Files\Microsoft\Exchange Server\V15\Mailbox\Mailbox Database 1

Usually this default location is not suitable, so you have two choices:

  • Remove the database and create a new one in the desired path
  • Move the existing database to the desired path

To move a database to a new location use the Move-DatabasePath cmdlet in the Exchange Management Shell.

Before you proceed please be aware that:

  • the command must be run while logged on to the mailbox server hosting the database
  • this process requires that the database be dismounted while the move takes place, making it unavailable for mailbox users
  • this process should not be followed for databases that are replicated within a Database Availability Group
  • this process cannot be run at the same time as a backup is in progress

Also consider that for non-replicated databases the best practice is still to separate the database file and transaction logs onto separate disks.

To move an Exchange 2013 database named “Mailbox Database 1″ to a new EDB file location of E:\Mailbox Database 1 and a new logs folder of F:\Mailbox Database 1 the following command is used.

[PS] C:\>Move-DatabasePath "Mailbox Database 1" -EdbFilePath "E:\Mailbox Database 1\Mailbox Database 1.edb" -LogFolderPath "F:\Mailbox Database 1"

Confirm
Are you sure you want to perform this action?
Moving database path "Mailbox Database 1".
[Y] Yes  [A] Yes to All  [N] No  [L] No to All  [?] Help (default is "Y"): y

Confirm
To perform the move operation, database "Mailbox Database 1" must be temporarily dismounted, which will make it
inaccessible to all users. Do you want to continue?
[Y] Yes  [A] Yes to All  [N] No  [L] No to All  [?] Help (default is "Y"): y

To check whether the database is mounted and accessible again you can run the following commands.

[PS] C:\>Get-MailboxDatabase -Status "Mailbox Database 1" | Select Name,Mounted

Name               Mounted
----               -------
Mailbox Database 1    True

[PS] C:\>Test-MAPIConnectivity -Database "Mailbox Database 1"

MailboxServer      Database           Result    Error
-------------      --------           ------    -----
E15MB1             Mailbox Database 1 Success
About Paul Cunningham

Paul is a Microsoft Exchange Server MVP and publisher of Exchange Server Pro. He also holds several Microsoft certifications including for Exchange Server 2007, 2010 and 2013. Find Paul on Twitter, LinkedIn or Google+, or get in touch for consulting/support engagements.

Comments

  1. So does Exchange 2013 not provide a way to move database file location from EAC ?

    Sachin

  2. Great article !
    Thanx

  3. THat is great info on how to move a database.

    How does one change the DEFAULT database location, or do we have to set it each time we create one?

    • If you run “Get-MailboxServer | select *datapath*” you’ll see the default data path. If I recall correctly it can’t be changed via a PowerShell command but can be changed using ADSIEdit.msc

  4. Joe Tuccillo says:

    For some reason I can not view my database in the EMC Servers > Database page of the ECP. I was able to move it through the shell but now can not see it to mount/dismount in the ECP? Any ideas why? Mail is flowing and everything else appears to be working. Thanks.

  5. Hello, I want to move the log files to different directory, i just want to know if i move the logs will the database be dismounted during the log move??
    Thank You

  6. works great thnx! :)

  7. Nausherwan says:

    I want to move my database file path only, I am running exchange 2013 CU2 in production. All databases are running in DAG and they have copies on other server, I want to change 4 Databases path from current location to other at both DAG members.
    Please confirm me about how to do this

  8. Hi Paul,

    Thanks for this instructive article, as usual on all your site!

    Since the process you described cannot be followed while my current database is on a 2 nodes DAG (2013 version),
    should i remove the DAG first and then recreate it again or is there a specific process allowing me to preserve it while doing the change ?

    Just to mention that i want to change the database location on only one node (in fact from one iscsi volume to another inside that same node)

    Thank you for your help.

  9. Hi Paul,

    I needed to move one database (part of a DAG) to a new location…
    I removed the database copy and then successfully moved the location, remounting without issue.
    I then added a new database copy and allowed it to recreate the copy on the 2nd DAG member from scratch.
    All went well.
    However… Although the Passive copy is Healthy, the Content Index State is FailedandSuspended and none of your previous tips help.
    I have tried removing the copy again, and recreating it again but to no avail.
    Do you have any suggestions?

    Thanks

    • If doing a reseed of the catalog only isn’t working try stopping search services on the failed node and deleting then content index folder for that DB copy, then start the services again. Give it 15-30 minutes to sort itself out then see if its healthy after that.

      Edit: I probably should have read the whole conversation below first. Looks like you’ve already done this.

      • Thanks Paul,

        I had already tried that.
        Do you have any experience with the Troubleshoot-CI scripts on Exchange 2013?
        Otherwise, looks like my only remaining option is to create a new DB and migrate the users mailboxes.

  10. Nausherwan says:

    Hi Graeme,

    I faced the same issue, after moving database location to new path, kindly update manually database copy (reseeding) and wait for 1-2 days, it all depends on the size of db file, when it will converge, content index state will be in healthy state.

    Regards,

  11. Hi Nausherwan,

    Thanks for your reply.
    I have been trying to resolve for 4 days. It is only a 5Gb database (7 users)
    I have tried manually updating the database copy, no change.
    Also tried:
    …Rebooting
    …Changing the Activation Preference
    …Removing the search folders (with Search services stopped and restarted)
    …Added ContentSubmitters AD Group (again with appropriate service stops and starts)

    Since Exchange 2013 (CU3) on 2012R2, not sure if I should modify the Troubleshoot-CI.ps1 to use the 2013 registry settings (Microsoft seem to have not updated the script for 2013… frustrating)

    I have other databases on this DAG, including new ones created in the past 2 days and no other issues.

    My last option seems to be to create a new mailbox database, add the copy, test replication, then move the users to the new mailbox database, finally retiring the old one. This seems extreme but I’m sure would fix the problem. My concern is if this happens to other mailbox databases…..

    Thanks

  12. Nausherwan says:

    have you tried this command with healthy source server switch, if it works

    Update-MailboxDatabaseCopy “dag2db1\mbox1″ -CatalogOnly -sourceserver

  13. Yep.
    The command should use the healthy source server by default, but I have also tried casting it explicitly.
    Again, thanks.

  14. Nausherwan says:

    To avoid any other issue, last option is to create new DB and its copy on other DAG member, move all users in New db, so that you can have alteast backup of that DB in the shape of DB copy in DAG.

    • Like I said though, that is a bit extreme and I’d rather understand and fix the problem so that if it happens to another database I can resolve again.

  15. I’m trying to move the database on exchange 2013. We are running exchange server using hyper-v on server 2012.

    I RDP into the mail server, open an exchange management shell using admin priv, but when the shell opens I get the warning ” Cant generate Export-module for the current session using Import-PSSession”

    When I run the command: “Move-DatabasePath “Mailbox Database xyz” -EdbFilePath “D:\mailstore\Mailstore1.edb” -LogFolderPath “D:\Mailstore”

    I get an error that the term ‘move-databasepath’ is not recognized.

  16. Worked for me, thanks Paul

  17. Steve Rackham says:

    Hi All
    I have inherited an exchange 2013 environment with a misconfigured DAG.
    It was initially configured with four servers (two DAGs with two nodes per DAG).
    I have reconfigured so that there is one DAG with all four MBX members as nodes.

    Unfortunately, when attempting to add-databasecopy I get this error -
    An existing database is already configured with the same location “E:\logs” for LogFolderPath.

    So, I need to to move the databases to each of there seperate folders.
    Currently set wtihout seperate folders :-/ lumped under a folder called databases and a log folder called Logs.
    I am better to create new databases? What is the process for moving a DAG database and Log path?

    Thanks for your help and good article.

    S.

    • So let’s say you’re trying to add a copy of DB01 to SERVER03… but SERVER03 already hosts a *different* database in the same DB/log paths as DB01.

      If that is the case, and that database has only a single copy right now, then you should be able to do the database move as shown in the article. It is only an issue moving database paths in DAGs for databases with more than one copy as far as I know.

Leave a Comment

*

We are an Authorized DigiCert™ SSL Partner.