Moving hMailServer DATA folder

This section contains user-submitted tutorials.
Post Reply
User avatar
Dravion
Senior user
Senior user
Posts: 2071
Joined: 2015-09-26 11:50
Location: Germany
Contact:

Moving hMailServer DATA folder

Post by Dravion » 2016-09-07 13:12

Sometimes the initial Installation drive is exausted by space or performance or you simply wish to replace the
Datafolder to an other SSD or Hardrive. You have to options to do it:

1) Change the Data folder entry to somewhere else and update all path entries in the SQL-DB to the new data folder.
2) Use symlinks (yes Windows supports them :) )

The procedures:
1) Open a Administrator Command prompt
2) Stop hMailserver service by typing: net stop hMailServer
3) Create a New physical Datafolder by typing: mkdir "C:\ProgramData\hMailServerData"
4) Change folder to with "cd "C:\Program Files (x86)\hMailServer"
5) Copy or move the content oft the folder C:\Program Files (x86)\hMailServer\data\ to C:\ProgramData\hMailServerData\
6) Type in: mklink /d Data "C:\ProgramData\hMailServerData"
7) net start hMailserver

hMailServer writes all data to C:\Program Files (x86)\hMailServer\data\ but Windows secretly redirects all
read/write operations to C:\ProgramData\hMailServerData\

Thats it.

braniak
Normal user
Normal user
Posts: 33
Joined: 2014-02-08 18:21

Re: Moving hMailServer DATA folder

Post by braniak » 2016-09-07 13:28

Cool. Thanks for sharing!

User avatar
Dravion
Senior user
Senior user
Posts: 2071
Joined: 2015-09-26 11:50
Location: Germany
Contact:

Re: Moving hMailServer DATA folder

Post by Dravion » 2016-09-07 13:47

Thx
You welcome :wink:

User avatar
jimimaseye
Moderator
Moderator
Posts: 10053
Joined: 2011-09-08 17:48

Re: Moving hMailServer DATA folder

Post by jimimaseye » 2016-09-07 13:52

Note that since Version 5.4 - Build 1931 the paths to the email files are not stored in the SQL database. Therefore links are not required to handle this. Hmailserver ini file just needs changing to point to the new data directory. Full details in the documentation: https://www.hmailserver.com/documentati ... _directory


1, Stop the hMailServer service
2, Move all the message files from the old to the new path
3, Open up hMailServer.ini
4, Specify the new path under the 'DataFolder=' entry
5, Restart the service

This also makes restore more robust as all paths are hardcoded and stored in the ini file and can be viewed and relied on upon on restore without missing the unmentioned/undocumented procedure of creating a link to redirect its stored destination path to another path.
5.7 on test.
SpamassassinForWindows 3.4.0 spamd service
AV: Clamwin + Clamd service + sanesecurity defs : https://www.hmailserver.com/forum/viewtopic.php?f=21&t=26829

User avatar
Dravion
Senior user
Senior user
Posts: 2071
Joined: 2015-09-26 11:50
Location: Germany
Contact:

Re: Moving hMailServer DATA folder

Post by Dravion » 2016-09-16 05:54

@jimimaseye

I think it would be a very nice feature request if the default data folder is
set to c:\ProgramData\hMailServerData and/or you can choose it in the Setup because
since Vista we have this https://msdn.microsoft.com/en-us/library/cc505883.aspx
in full force on x:\Program files\ x:\Program files (x86\
ProgramData specifies the path to the program-data folder (normally C:\ProgramData). Unlike the Program Files folder, this folder can be used by applications to store data for standard users, because it does not require elevated permissions.
https://technet.microsoft.com/en-us/lib ... 15936.aspx

User avatar
mattg
Moderator
Moderator
Posts: 22435
Joined: 2007-06-14 05:12
Location: 'The Outback' Australia

Re: Moving hMailServer DATA folder

Post by mattg » 2016-09-16 08:50

https://github.com/hmailserver/hmailserver/issues/98

Martin has flagged that as a bug, and earmarked it for 5.7 release
Just 'cause I link to a page and say little else doesn't mean I am not being nice.
https://www.hmailserver.com/documentation

BeeTee
New user
New user
Posts: 20
Joined: 2011-06-14 11:00

Re: Moving hMailServer DATA folder

Post by BeeTee » 2021-03-19 09:33

A big thank you to @Dravion for sharing the symlink trick :) :)

I do know about symlink but wasn't thinking as clear as Dravion do to get the idea myself :-P

Especially useful if you want to place one or more mailboxes on other/new storage.

One could say it would be great if hMailserver supported storage-specification per-domain or per-mailbox instead of per-server, but symlink do the trick.

BeeTee
New user
New user
Posts: 20
Joined: 2011-06-14 11:00

Re: Moving hMailServer DATA folder

Post by BeeTee » 2021-03-22 12:54

I thought the paths are not saved in the database? If so, how does hmailserver know about the old path if I change it in the ini?

User avatar
mattg
Moderator
Moderator
Posts: 22435
Joined: 2007-06-14 05:12
Location: 'The Outback' Australia

Re: Moving hMailServer DATA folder

Post by mattg » 2021-03-23 01:43

BeeTee wrote:
2021-03-22 12:54
I thought the paths are not saved in the database? If so, how does hmailserver know about the old path if I change it in the ini?
It doesn't, that's the point

You can move the data directory and reset the ini setting, restarting hMailserver and all will continue to work (with the new path)
Just 'cause I link to a page and say little else doesn't mean I am not being nice.
https://www.hmailserver.com/documentation

Post Reply