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

Comments

  1. Bob says

    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?

    • says

      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

  2. 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.

  3. Hesan says

    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

  4. 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

  5. Eric says

    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.

  6. Graeme says

    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

    • says

      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.

      • Graeme says

        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.

  7. 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,

  8. Graeme says

    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

  9. Nausherwan says

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

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

  10. Graeme says

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

  11. 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.

    • Graeme says

      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.

  12. Tom says

    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.

  13. 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.

    • says

      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.

      • Raman says

        Hi Paul,
        I just wanted to confirm, we are Exchange 2013 SP1 in DAG. We have 1 Active and 1 Passive copies of all DBs. Currently we have all DBs are in separate folders. Ex: DB1 has a separate folder on F:\DB1 and this folder has DB1.edb and DB1 Logs as well. DB2 has its own separate folder F:\DB2 and this folder has DB2.edb and DB2 logs.
        Do I need to move EDB files and Log files of same DB in separate folders as well?
        Thanks,
        Raman

  14. Tofik says

    Hi Paul,

    I have an Exchange 2013 server which is also a DC and DNS server. Now, I need to move it from there to a new server and remove the current server from my environment. The exchange is running on Microsoft Windows 2012 R2. Is there any step by step guide?

    Thank you,
    Tofik

  15. Dominik says

    It’s been high time I thanked you for all those great tips you post on this blog, you’ve saved my bacon on more than one occasion already!

    Keep up the great work!

  16. Matt says

    “This operation cannot be performed on a remote server. Please use the -ConfigurationOnly option and then manually move the files” From every server I have run this command on regardless of where the log files and the db files are located.

    Command simply does not work in any way at all from what I can see. Same error when logged into the server hosting the db and logs as when not.

  17. Abhijeet says

    Hi Paul,

    I have exchange 2013 which have 2 DAG’s with 2 DB’s, which is running X (SAN)Storage , I need to migrated to Y (SAN) storage without impacting users , Due to lack of storage space in existing SAN future requirement

    Please advice migration method

      • Abhijeet says

        Hi Paul,

        Thanks your advice ,

        1. How to calculate, how many mailbox’s. I can be migrate in a days, As I have 14 TB Data ( is any calculator available )

        2. Are you advising to Create New DAG for New database on new SAN, then move mailboxes from source DB to New Target DB ?

        Please advise

        • says

          1. Move some mailboxes and work out how fast they’re moving, then use that to calculate how long the rest of your migration will take.

          2. I see no reason to create a new DAG.

  18. Abhijeet says

    Thank you so much …

    So you are adviseing add this new database in existing DAG

    I have same size of db size 14 TB on DR location also, so once I move mailbox from old db to new db it will replicate to passive copy which is in DR location, am I correct?

    • says

      Yes. Create the new database on one of your DAG members, then add a copy of that database to your other DAG members. Everything you migrate into that new database will then automatically be replicated to the other copies of that database.

Leave a Reply

Your email address will not be published. Required fields are marked *