Post new topic Reply to topic  [ 11 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: 6394
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: 6394
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: 104
UPDATE hm_messages SET messagefilename=REPLACE(messagefilename,'C:\\Program Files\\hMailServer\\Data','S:\\hMailServer\\Data')


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 11 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