Post new topic Reply to topic  [ 16 posts ] 
Author Message
 Post subject: HowTo: Move data directory
PostPosted: 2009-05-04 18:43 
New user
New user

Joined: 2008-09-01 19:45
Posts: 19
This is just a short description how to move your datadirectory to a new location (or other drive). Although there r some descriptions how to move the data, or to change the database, i somehow missed a "whole" thing. It is written for Hmailserver 5.1 using a mysql database and a php engine (apache). It should work fine with older versions. If you use another DB system u have to modify some steps concerning the db. Use this description at your own risk. I did write it down from my memory, so some steps might be mixed up when it comes to the setup of hmailserver. And english is obviously not my first language, so there might be some mixups too. Nevertheless i hope i can give clueless guys some hints how to do this.

Problems discussed:
- Hmailserver uses a db to save the path to EVERY email. If u change the dir, u HAVE TO change the content of the db.
- mysql isnt shipped anymore with hmailserver
- Hmailserver sets up envirometnal variables, which are cheesy to edit by hand.

Lets get started.

Step 1:
Stop HMailserver.

Step 2:
Backup your datadirectory, your hmailserver.ini and your database for safety reasons.

If you dont do that allready on a regular basis - START NOW. You will find your directories most likely in the hmailserver installation folder. It should be something like c:\program files (x86)\hmailserver\data and bin.

Hint: For data backup, use CobianBackup. For your mysql server either use phpmyadmin, or mysqldumper (which is pretty powerful backup solution written in php)(couldnt find english version right now).

After the backup of the database, rename the hmailserver table to whatsoever. We will use it later again.

Step 3:
Re-Install HMailserver.

Because HMailserver sets some enviromental variables it is way more easy to deinstall the server and do a new setup on the prefered drive, than changing everything by hand.
De-Install Hmailserver.
Load the latest stable version from http://www.hmailserver.com and install it on your prefered drive..

Step 4:
Follow the guide, till it asks you for your db solution. As mentioned above this minitut is going to use mysql.
Choose to create a new database, since we will use the old one anyways. (I couldnt use the second option it just kept quitting without mentioning what went wrong).
The wizard will ask you for your login data.
Commonly its localhost (try 127.0.0.1 if localhost wont work) and the preset port. Use your username and password, as well as a databasename. The database will be created by hmailserver.

HMailserver will now try to connect to the database and will most likely fail. This is because of the closed source policy of mysql. Hmailserver is not shipped with the necessary libmysql.dll anymore. Copy the dll from your local Apache setup configuration to the your new hmailserver/bin folder. Do not use the libmysql.dll which is sometimes shipped with windows. It will not work. If you are using xampp or something similar, search the mysql/bin folder.

Try to reconnect to the db and be patient. If the connection error still apears, check the screen output (seriously) and/or check your username and password for the db.

Step 5:
Finish setup.
Set up the necessary login data for your hmailserver adminpanel.

Step 6:
Acquiring new data path.
Go to your new hmailserver folder and open the hmailserver.ini. Check the line with the datadirectory. Copy the path, we will need it change our old database.

Step 7:
Changing your database.

Use this simply and dirty script to change your database (the old 1, u renamed in before).

Code:
<?
$old_path = 'd:\hMailServer\Data'; // do not end on a backslash here, it will cause errors if unescaped
$new_path = 'd:\hMailServer\Data'; // do not end on a backslash here, it will cause errors if unescaped


$link = mysql_connect("localhost", "username", "password") // your connection data here
   or die("No connection possible: " . mysql_error());
mysql_select_db("hmailserver") or die("db selection failed"); // your dbname here

$change_data = mysql_query("   UPDATE
                             hm_messages
                     SET
                             messagefilename=REPLACE(messagefilename,'".mysql_real_escape_string($old_path)."','".mysql_real_escape_string($new_path)."')
                  ") or die(mysql_error());


Step 8:
Rename your changed old db to be the new one. Use the db_updater located in the hmailserver directory to get it up to date.

Step 9:
Done. Start HmailServer.


Top
 Profile  
 
 Post subject: Re: HowTo: Move data directory
PostPosted: 2009-06-11 13:57 
New user
New user

Joined: 2009-06-11 13:17
Posts: 2
Hi,

Please Help me on that.

I installed MySQL database in my debian box. Now,How i can locate my "data directory" of MySQL and i need to move the "data directory" alone to some other location,and MySQL need to point the data directory location.

Thanks in Advance

_________________
Intelemark


Top
 Profile  
 
 Post subject: Re: HowTo: Move data directory
PostPosted: 2009-06-11 14:18 
New user
New user

Joined: 2008-09-01 19:45
Posts: 19
Im not familiar with the directorysettings on your machine.

If u want solely to move ur mysql dir u can just backup ur db.


Top
 Profile  
 
 Post subject: Re: HowTo: Move data directory
PostPosted: 2009-06-15 22:17 
Normal user

Joined: 2005-12-12 14:15
Posts: 49
Sorry to ask that stupid question:

where should I put the script in? I tried to use it in the MySQL Query Browser, but that did not work...

Thanks, Markus


Top
 Profile  
 
 Post subject: Re: HowTo: Move data directory
PostPosted: 2009-06-15 22:24 
New user
New user

Joined: 2008-09-01 19:45
Posts: 19
Save as changedir.php, put it into ur htdocs folder. U will need an apache, or IIS with php extension (or some kind of server which is capable of interpreting php).

Change paths in the script. Run it as u would any normal php script.

U could however do the query by hand. Phpmyadmin could come in handy. The query would be very similar to the one used in the script.

Remember to backup 1st.


Top
 Profile  
 
 Post subject: Re: HowTo: Move data directory
PostPosted: 2009-07-17 17:55 
New user
New user

Joined: 2008-11-07 18:39
Posts: 15
Do you really have to do an uninstall and reinstall to change just the data folder?

What environmental variables does hmailserver have?


Top
 Profile  
 
 Post subject: Re: HowTo: Move data directory
PostPosted: 2009-07-17 17:59 
Developer

Joined: 2003-11-21 01:09
Posts: 6403
Location: Sweden
> Do you really have to do an uninstall and reinstall to change just the data folder?

No?

> What environmental variables does hmailserver have?

What precisely do you mean by this?


Top
 Profile  
 
 Post subject: Re: HowTo: Move data directory
PostPosted: 2009-07-17 18:15 
New user
New user

Joined: 2008-11-07 18:39
Posts: 15
from first post
Problems discussed:
- Hmailserver uses a db to save the path to EVERY email. If u change the dir, u HAVE TO change the content of the db.
- mysql isnt shipped anymore with hmailserver
- Hmailserver sets up envirometnal variables, which are cheesy to edit by hand.

would i be correct in thiking i could just
1. stop service
2. move files to new folder
3. change the hMailServer.INI file to point to the new folder
4. change the messagefilename in db to point to new folder?


Top
 Profile  
 
 Post subject: Re: HowTo: Move data directory
PostPosted: 2009-07-17 18:20 
Developer

Joined: 2003-11-21 01:09
Posts: 6403
Location: Sweden
I understand what you mean now.

> would i be correct in thiking i could just

Yes. This topic is just misleading. There's no point in reinstalling hMailServer if all you want to do is change the data directory. I'll probably delete this topic ...


Top
 Profile  
 
 Post subject: Re: HowTo: Move data directory
PostPosted: 2009-07-17 18:21 
New user
New user

Joined: 2008-11-07 18:39
Posts: 15
anyone know a quick mssql query to change the filename in the db? even if its only c: to d:


Top
 Profile  
 
 Post subject: Re: HowTo: Move data directory
PostPosted: 2009-07-31 21:52 
Normal user

Joined: 2009-07-31 21:50
Posts: 111
UPDATE hm_messages SET messagefilename=REPLACE(messagefilename,'C:\\Program Files\\hMailServer\\Data','S:\\hMailServer\\Data')


Top
 Profile  
 
 Post subject: Move data directory in Windows Server 2012/Windows 7 (Solved
PostPosted: 2014-02-18 14:45 
New user
New user

Joined: 2014-02-18 14:24
Posts: 1
I had some problems, changing the data folder path using this tutorial. Here my experiences:

    Changing the data path in hmailserver.ini hat no effect, even after clicking stop/resume in hMailServer Status Tab.
    Reinstallation of hMailserver brought error with something like "... COM-..." (I forgot), but I had to recover an old backup

Finaly I managed it:
    1. Stop hMailserver Service directly in Windows (http://technet.microsoft.com/en-us/library/cc736564%28v=ws.10%29.aspx). The button Stop/Resume in hMailserver does not stop the hmailserver-service; whatever they say.
    2. Copy all files to the new directory.
    3. Change bin\hmailserver.ini in the way: DataFolder=D:\.... (Use quotes if spaces in the path)
    4. Change in the SQL-database hm_messages the path using the query written by sckramer2. I used the search/replace-function in MySQL-Front. Newer entries in hm_messages do not have a absolute path, so this step might be unnecessary, just check.
    5. Open hMailServer Administrator and the service will start again automatically.
    6. Enjoy :-)
It is NOT necessary to reinstall hmailserver. Don't do it!


Top
 Profile  
 
 Post subject: Re: Move data directory in Windows Server 2012/Windows 7 (So
PostPosted: 2014-02-18 17:08 
Developer

Joined: 2010-04-24 23:16
Posts: 5785
Location: Michigan, USA
seebold wrote:
I had some problems, changing the data folder path using this tutorial. Here my experiences:

    Changing the data path in hmailserver.ini hat no effect, even after clicking stop/resume in hMailServer Status Tab.
    Reinstallation of hMailserver brought error with something like "... COM-..." (I forgot), but I had to recover an old backup

Finaly I managed it:
    1. Stop hMailserver Service directly in Windows (http://technet.microsoft.com/en-us/library/cc736564%28v=ws.10%29.aspx). The button Stop/Resume in hMailserver does not stop the hmailserver-service; whatever they say.
    2. Copy all files to the new directory.
    3. Change bin\hmailserver.ini in the way: DataFolder=D:\.... (Use quotes if spaces in the path)
    4. Change in the SQL-database hm_messages the path using the query written by sckramer2. I used the search/replace-function in MySQL-Front. Newer entries in hm_messages do not have a absolute path, so this step might be unnecessary, just check.
    5. Open hMailServer Administrator and the service will start again automatically.
    6. Enjoy :-)
It is NOT necessary to reinstall hmailserver. Don't do it!

Indeeed seebold the main reason the button in the GUI admin was renamed from Stop/Start to Pause/Resume in 5.4 was to make it more obvious it was NOT the same as Stop/Start/Restart in Windows service management! I went beyond that & put a note below the button that says (Use Windows to Start/Stop Service). Surely those 2 things give enough clues.. Or must I also add a popup dialog with more details & an agreement button? ;) Also keep in mind this howto was created back in 2009 well before 5.4.
Bill

_________________
hMailServer build LIVE on my servers: 5.4-B2014011501
Latest test builds: http://www.hmailserver.com/forum/viewtopic.php?f=10&t=21420
Urgent? Bored? JOIN US ON IRC!
DOGE ME: DSqtEcqP3Qv6Tj2XrGNpDmEUkSBcpBsuWk


Top
 Profile  
 
 Post subject: Re: HowTo: Move data directory
PostPosted: 2014-02-19 01:05 
Moderator
User avatar

Joined: 2007-06-14 05:12
Posts: 11347
Location: 'The Outback' Australia
Yep, all much easier since this thread was last updated some 4 years ago....

Must be the new version, Bill. :mrgreen:

I suspect that seebold was using an older version due to the fact that they didn't see your renaming of those buttons?

_________________
Just 'cause I link to a page and say little else doesn't mean I am not being nice.
Documentation


Top
 Profile  
 
 Post subject: Re: HowTo: Move data directory
PostPosted: 2014-03-05 12:09 
New user
New user

Joined: 2014-02-27 13:51
Posts: 1
Location: USA
i am worried how can i move the data this forum is help me to understand the process.


Top
 Profile  
 
 Post subject: Re: HowTo: Move data directory
PostPosted: 2014-03-05 14:10 
Moderator
User avatar

Joined: 2007-06-14 05:12
Posts: 11347
Location: 'The Outback' Australia
Please start a new thread and link back to this one if you see fit, but seriously, a little more information is required.

Where are you moving data directory to & from
What version of hMailserver

_________________
Just 'cause I link to a page and say little else doesn't mean I am not being nice.
Documentation


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 16 posts ] 


Who is online

Users browsing this forum: No registered users and 2 guests



Search for:
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group