how move data folder to a different (bigger) drive?

Use this forum if you have installed hMailServer and want to ask a question related to a production release of hMailServer. Before posting, please read the troubleshooting guide. A large part of all reported issues are already described in detail here.
Post Reply
peterj
New user
New user
Posts: 3
Joined: 2008-10-05 21:40

how move data folder to a different (bigger) drive?

Post by peterj » 2008-10-05 21:49

my current installation is on C: but I have just got a bigger (faster) drive, and I want to move all of my existing data (messages) to this new drive. How do I do this? Thanks

User avatar
martin
Developer
Developer
Posts: 6834
Joined: 2003-11-21 01:09
Location: Sweden
Contact:

Re: how move data folder to a different (bigger) drive?

Post by martin » 2008-10-05 22:00

It's tricky since there are no built-in functionality for it.

There are three things which needs to be done. If you skip one of them, messages currently on the server will become unavailable.

1) The paths in the hm_messages table in the hMailServer database must be updated. For every message in the database, the full path to the message file is specified. To do this, you must connect to the database server using a SQL client and issue an UPDATE command on the hm_messages table. If you have no experience with SQL, this will be the hard part.
2) The data directory path in hMailServer.ini must be updated.
3) The messages must be moved.

peterj
New user
New user
Posts: 3
Joined: 2008-10-05 21:40

Re: how move data folder to a different (bigger) drive?

Post by peterj » 2008-10-05 22:12

can you suggest a "simple" SQL client. I have done a little bit of sql, and prefer a more visual tool rather than command line tool.

User avatar
martin
Developer
Developer
Posts: 6834
Joined: 2003-11-21 01:09
Location: Sweden
Contact:

Re: how move data folder to a different (bigger) drive?

Post by martin » 2008-10-05 22:21

Depends what database engine you're using. If it's MySQL, SQLyog is pretty simple.
I forgot one important step:
0) Backup your database prior to running any SQL statements in it...

peterj
New user
New user
Posts: 3
Joined: 2008-10-05 21:40

Re: how move data folder to a different (bigger) drive?

Post by peterj » 2008-10-05 22:26

I'd taken step 0 as read :) I am using MySQL, so I'll give your suggestion a go - although not at the moment (it's Sunday evening and the wine is starting to have its effect!). I'll post back with the results. Thanks

User avatar
martin
Developer
Developer
Posts: 6834
Joined: 2003-11-21 01:09
Location: Sweden
Contact:

Re: how move data folder to a different (bigger) drive?

Post by martin » 2008-10-05 22:46

I haven't tried this myself, so please don't assume it will work. Really, don't. :)
1) Execute the following statement:
SELECT CONCAT('C:\\Data\\', SUBSTRING(messagefilename, 35)) FROM hm_messages
2) Confirm that the paths in the result of the SELECT statement is correct. If not, don't continue. If the paths are incorrect and you'll continue, you'll not be able to access your email.
3) Execute the following statement:
UPDATE hm_messages SET messagefilename = CONCAT('D:\\Data\\', SUBSTRING(messagefilename, 35))
35 comes from the length of your current data directory, which I assume is "C:\Program Files\hMailServer\Data\"

And again, backups when doing this is essential.

qwarrior
New user
New user
Posts: 1
Joined: 2008-05-21 12:10

Re: how move data folder to a different (bigger) drive?

Post by qwarrior » 2008-11-21 17:47

You've probably sorted this by now but if an alternative is to usse the MySQL replace function:

UPDATE hm_message SET messagefilename=REPLACE(messagefilename,'OldPath','NewPath');

remember to use \\ instead of \ in your paths depending on your MySQL settings.

:)

User avatar
martin
Developer
Developer
Posts: 6834
Joined: 2003-11-21 01:09
Location: Sweden
Contact:

Re: how move data folder to a different (bigger) drive?

Post by martin » 2008-11-21 18:18

Yes, that's a good alternative, if it works. When I wrote the original suggestion in my previous post, I tried to use the REPLACE function but couldn't get it to work properly with the slashes. Tested a lot of things (such as escaping with \\) but the results weren't correct. Which is why I gave the more complex suggestions. :-\

As long as you do a backup and confirm that the result is correct (using SELECT * FROM hm_messages LIMIT 0,100) after you've run the UPDATE-statement, your suggestion is probably better as a generic solution.

boogieman
New user
New user
Posts: 10
Joined: 2009-05-21 13:03

Re: how move data folder to a different (bigger) drive?

Post by boogieman » 2009-11-28 01:24

have the same situation here - is the suggestion still the same for v. 5.3?

thanks!

^DooM^
Site Admin
Posts: 13861
Joined: 2005-07-29 16:18
Location: UK

Re: how move data folder to a different (bigger) drive?

Post by ^DooM^ » 2009-11-28 01:38

Yes
If at first you don't succeed, bomb disposal probably isn't for you! ヅ

boogieman
New user
New user
Posts: 10
Joined: 2009-05-21 13:03

Re: how move data folder to a different (bigger) drive?

Post by boogieman » 2009-11-28 01:53

ok will give it a shot :)
thanks!

Post Reply