Moving dovecot mail server from one server to another

So, I’ve decided I need to move from one server to another. The site has been moved already, but now it’s time to move the mail server. It’s been a while since I set it up, so I’ve probably forgotten a bit how it was set up in the first place.

First I’ll start with backing up the vmail folder on the old server.

Then I’m copying this over to the new server, extracting it on the same location on the new server.

That’s the data. But we need the database controlling it all aswell. So we’ll export the sql data.

To import it I first had to create the database on the new server. First login on the mysql server, then:

And the import command:



Now, on the new server I still haven’t installed any mail software. Since I was using postfix/dovecot on the old server, I’ll go for the same on the new one.

There, now I’ve installed the software, all I need to do is to set it up.

First of all I want to try to just copying the config files from the old server over to the new one. Hopefully that will work.

From the postfix configuration directory (/etc/postfix) I copy In this directory I’ve also created a directory named virtual where I store my sql commands for the virtual mailboxes. So I copy this directory over aswell.

As far as I can remember that’s  all the configuration I did with postfix. Now for dovecot.

In /etc/dovecot/ I’m copying dovecot.conf and dovecot-sql.conf over to the new server.

On my old server I was using Roundcube as a web mail solution, so I’ll go for the same on the new server.

I won’t bother to reuse the configuration on this, so I’m just plainly installing it with:


After setting that up, now I’ve changed the MX-records on the DNS, and I’ll just have to wait for it to update to check if everything’s working like it should.

WordPress php sql running twice

Wordpress logoI was making this small feature in php where I want a script to collect links. What I want to do is have a text input box and a submit button. When you hit submin, the link gets added to a database and all the links in the database gets loaded on the same page as the form.

I’m using the plugin Exec-PHP to run a php file as an include on a page. When I run the included file as standalone, without it being integrated in a WordPress page, the script runs fine and does exactly what I want it to do. All that is performed is a simple SELECT statement to extract all the links from the database and show them. When the user press submit, the script checks that the text in the input box is an URL, and adds it to the database with an INSERT statement.

This is where I’ve run into problems. When run as standalone it all works fine, but when I run it inside WordPress it runs the INSERT statement twice. The SELECT statements are only run once though.

For a live demonstration take a look at links inside WordPress and standalone outside WordPress

Is there a reason for this? I was thinking anyway to write this as a plugin to WordPress instead as I’m guessing there are various hooks in WordPress that makes it run twice. We’ll see if that solves the problem.



I thought maybe using WordPress‘s builtin database functions would help me solve the problem, but still the INSERT queries keep being run twice. I came up with a dirty hack, checking if the link was already in the database before I inserted it, wich I was going to implement either way so there is no double posted links. But that deprived me of the ability to give the user feedback on the link being added, or the link existing already in the database. So, I have to come up with another solution to this problem to make it work correctly like I want it to.