The Disappearing Roundcube Address Book 2013-11-16
I use a webmail thingy called Roundcube which lets me read my email with my web browser like GMail or Hotmail (or most other crappy ass advertising driven mail providers). One of the configuration settings in Roundcube is where you tell it how to find your mail server... so it can read and send email of course. Another setting is where to find the database for storing user preferences. Unfortunately these two settings are more related than you might think... if you change the IP address (or DNS name) of your mail server then your Roundcube installation might not be able to find your address books (and other user settings) - because the location of these things in the database is tied to the address of the server! I have changed my mail server address a couple of times and both times it has screwed up my Roundcube install. Both times I was able to get my shit back thanks to this post by Nikolay Hristov. I am just duplicating his information here (with some minor modifications) in case his site ever changes or disappears or whatever... all credit should go to him of course.
When your Roundcube server's IP address changed you had to make some modifications to its config to get it working again. You probably stopped right there and assumed your work was done... but it may not be. Some users may report that their address books have disappeared! In fact the entries are not missing, but rather Rouncube shows only entries for the users with current 'default_host' IP address. This means that when you changed the IP address to make Roundcube work again, you broke the link in the database to all the users settings. Most users will probably notice their missing address book before any other problems this may have caused. So now you have two entries in the database for each user, one with the original 'default_host' field and one with the new 'default_host' field. In other words, the user "Joe" created and populated his address book as "10.10.200.1\Joe" but now when he logs in he is treated as "192.168.10.1\Joe". How do you fix this?
To start, you will need to know the OLD IP address, and the NEW IP address, and you'll need to be able to log in to mysql as a user with permissions to run the commands below on the roundcube database. The current IP address can probably be found in the config/main.inc.php file which is the Roundcube config file you had to modify when the IP address changed. For example:
$rcmail_config['default_host'] = '192.168.10.1';
Of course, your IP address is probably different. The old IP address you should remember from when you changed he main.inc.php file, or may have to read from the database. I remembered mine so I don't have a database search command handy. Step one will be to delete any of the settings and address books that were created since the IP address change. This is done by logging in to mysql and running these commands (note that the IP address in this part is the NEW IP address):
# mysql -u roundcubeuser -proundcubepass
mysql> use roundcube
mysql> delete from users where mail_host='192.168.10.1';
Then you need to change all the old settings and address books to appear under the new IP address for each user. Note again that the 192.168.10.1 address is the new one - it is important not to get your IP addresses swapped when doing this.
mysql> update users set mail_host='192.168.10.1' where mail_host='10.10.200.1';
Mysql should reply by telling you how many rows were changed, and the number should match the number of users you have.