Wednesday, July 7, 2010

How to move Openfire Chat server to another PC/Server


Although there are alot of forums about this subject, most of the information on google is stale. I have used Openfire 3.6.4 and MySQL Essential 5.1.41 on Windows 2003 Server R2.
On the old machine:
1.       Goto Start > Administrative Tools > Services (on XP, Start> Control Panel> Administrative Tools>Services)
2.       Stop MySQL and Openfire services (Openfire service may not be available if you havent set it to run as a service before - doesnt matter.)
3.       Goto C:\Program Files\ folder (where MySQL and Openfire folders are installed).
4.       Backup Zip or Rar both entire MySQL and Openfire folders (to a USB disk would be handy).
5.       Note the MySQL username and password, which will become handy.
6.       Open a Command Prompt from Windows and goto C:\Program Files\MySQL\MySQL Server 5.1\bin folder
7.       Execute the command:
mysqldump -u user_name -ppassword databasename > backupfile.sql
[user_name]          Your database username
[password]             The password for your database (note that there is no space between -p and the password)
[databasename]    The name of your database
[backupfile.sql]      The filename for your database backup

For example, the command will look similar to this:
mysqldump -u root –p12345 openfire > openfire.sql

·         In most sites its telling you to run the above command from command line, but not command prompt.
·         Thats why the novices like us, try to run the above command from the MySQL Command line client.
·         ABOVE command must be run from Command Prompt at C:\Program Files\MySQL\MySQL Server 5.1\bin folder.
Depending on your database size, it will take sometime to dump the database to openfire.sql file. It will create the openfire.sql file on the same subfolder (in this case, \bin)
8.       Copy the openfire.sql file to a media (usb disk etc.) to be used on the other machine.

On the New machine:
1.       Install a clean MySQL Server with default settings. (its a good idea to  set the root password same as the old machine’s MySQL Server – as long as the version of the software is over 5.1, it doesn’t have to be the same version).
2.       Copy the openfire.sql file which you backed up earlier, to the C:\Program Files\MySQL\MySQL Server 5.1\bin folder.
3.       Open a Command Prompt and goto C:\Program Files\MySQL\MySQL Server 5.1\bin folder.
4.       If you try to restore your database into the new mysql server directly, it will reject it with “database unknown” error.
As a workaround, within the \bin folder at Command Prompt
Execute the command:
mysqladmin create databasename (databasename must be identical to the one you have backed up earlier)
5.       To inject your backed up database into the new MySQL Server Execute the command:
mysql -u user_name –p password databasename < backupfile.sql
[user_name]          Your database username
[password]             The password for your database (note that there is no space between -p and the password)
[databasename]    The name of your database
[backupfile.sql]      The filename for your database backup
For example, the command will look similar to this: mysqldump -u root –p 12345 openfire < openfire.sql
6.       After the command is completed, install Openfire setup program with default settings. Do NOT configure Openfire.
7.       After the Openfire clean installation is complete, Goto Start > Administrative Tools > Services (on XP, Start> Control Panel> Administrative Tools>Services)
8.       Stop MySQL service
9.       Navigate to the Openfire directory
10.   Unzip and overwrite the Openfire directory with the previously backed up Openfire contents of the old machine. (while overwriting, explorer may warn or halt you about not being able to over-write some files. The active files can be stopped via task manager and continue overwrite.)
11.   When the overwrite process is complete, navigate back to the Services window and start the MySQL service.
12.   From the Start button click on Openfire Server
13.   When the Openfire Server is started Launch Admin page and check your settings, which should be identical to the ones on old server.