Qmail migration on New Server

>Check out the vpopmail database is created with the proper credential on new system where we are migrating
——————————————————————————–
#First created database
#mysql -uroot -p -e ‘CREATE DATABASE vpopmail’
#mysql -uroot -p -e “GRANT ALL PRIVILEGES ON vpopmail.* TO qmailuser@localhost IDENTIFIED BY ‘password'”;
qmailuser/password is credentials for mysql which is stored on/home/vpopmail/vpopmail.mysql

If table structure is not populated, Please copy the following in italic format and save on .sql file.

Restore the following structure on newly created vpopmail database on new system.
————————————————————————————-
/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */;
/*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */;
/*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */;
/*!40101 SET NAMES utf8 */;
/*!40014 SET @OLD_UNIQUE_CHECKS=@@UNIQUE_CHECKS, UNIQUE_CHECKS=0 */;
/*!40014 SET @OLD_FOREIGN_KEY_CHECKS=@@FOREIGN_KEY_CHECKS, FOREIGN_KEY_CHECKS=0 */;
/*!40101 SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE=’NO_AUTO_VALUE_ON_ZERO’ */;
/*!40111 SET @OLD_SQL_NOTES=@@SQL_NOTES, SQL_NOTES=0 */;


— Table structure for table `dir_control`

DROP TABLE IF EXISTS `dir_control`;
CREATE TABLE `dir_control` (
`domain` char(64) NOT NULL default ”,
`cur_users` int(11) default NULL,
`level_cur` int(11) default NULL,
`level_max` int(11) default NULL,
`level_start0` int(11) default NULL,
`level_start1` int(11) default NULL,
`level_start2` int(11) default NULL,
`level_end0` int(11) default NULL,
`level_end1` int(11) default NULL,
`level_end2` int(11) default NULL,
`level_mod0` int(11) default NULL,
`level_mod1` int(11) default NULL,
`level_mod2` int(11) default NULL,
`level_index0` int(11) default NULL,
`level_index1` int(11) default NULL,
`level_index2` int(11) default NULL,
`the_dir` char(160) default NULL,
PRIMARY KEY (`domain`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1;


— Table structure for table `lastauth`

DROP TABLE IF EXISTS `lastauth`;
CREATE TABLE `lastauth` (
`user` char(32) NOT NULL default ”,
`domain` char(64) NOT NULL default ”,
`remote_ip` char(18) NOT NULL default ”,
`timestamp` bigint(20) NOT NULL default ‘0’,
PRIMARY KEY (`user`,`domain`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1;


— Table structure for table `limits`

DROP TABLE IF EXISTS `limits`;
CREATE TABLE `limits` (
`domain` char(64) NOT NULL default ”,
`maxpopaccounts` int(10) NOT NULL default ‘-1’,
`maxaliases` int(10) NOT NULL default ‘-1’,
`maxforwards` int(10) NOT NULL default ‘-1’,
`maxautoresponders` int(10) NOT NULL default ‘-1’,
`maxmailinglists` int(10) NOT NULL default ‘-1’,
`diskquota` int(12) NOT NULL default ‘0’,
`maxmsgcount` int(12) NOT NULL default ‘0’,
`defaultquota` int(12) NOT NULL default ‘0’,
`defaultmaxmsgcount` int(12) NOT NULL default ‘0’,
`disable_pop` tinyint(1) NOT NULL default ‘0’,
`disable_imap` tinyint(1) NOT NULL default ‘0’,
`disable_dialup` tinyint(1) NOT NULL default ‘0’,
`disable_passwordchanging` tinyint(1) NOT NULL default ‘0’,
`disable_webmail` tinyint(1) NOT NULL default ‘0’,
`disable_relay` tinyint(1) NOT NULL default ‘0’,
`disable_smtp` tinyint(1) NOT NULL default ‘0’,
`perm_account` tinyint(2) NOT NULL default ‘0’,
`perm_alias` tinyint(2) NOT NULL default ‘0’,
`perm_forward` tinyint(2) NOT NULL default ‘0’,
`perm_autoresponder` tinyint(2) NOT NULL default ‘0’,
`perm_maillist` tinyint(4) NOT NULL default ‘0’,
`perm_quota` tinyint(2) NOT NULL default ‘0’,
`perm_defaultquota` tinyint(2) NOT NULL default ‘0’,
PRIMARY KEY (`domain`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1;


— Table structure for table `valias`

DROP TABLE IF EXISTS `valias`;
CREATE TABLE `valias` (
`alias` varchar(32) NOT NULL default ”,
`domain` varchar(64) NOT NULL default ”,
`valias_line` text NOT NULL,
KEY `alias` (`alias`,`domain`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1;


— Table structure for table `vlog`

DROP TABLE IF EXISTS `vlog`;
CREATE TABLE `vlog` (
`id` bigint(20) NOT NULL auto_increment,
`user` varchar(32) default NULL,
`passwd` varchar(32) default NULL,
`domain` varchar(64) default NULL,
`logon` varchar(200) default NULL,
`remoteip` varchar(18) default NULL,
`message` varchar(255) default NULL,
`timestamp` bigint(20) NOT NULL default ‘0’,
`error` int(11) default NULL,
PRIMARY KEY (`id`),
KEY `user_idx` (`user`),
KEY `domain_idx` (`domain`),
KEY `remoteip_idx` (`remoteip`),
KEY `error_idx` (`error`),
KEY `message_idx` (`message`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1;


— Table structure for table `vpopmail`

DROP TABLE IF EXISTS `vpopmail`;
CREATE TABLE `vpopmail` (
`pw_name` char(32) NOT NULL default ”,
`pw_domain` char(64) NOT NULL default ”,
`pw_passwd` char(40) default NULL,
`pw_uid` int(11) default NULL,
`pw_gid` int(11) default NULL,
`pw_gecos` char(48) default NULL,
`pw_dir` char(160) default NULL,
`pw_shell` char(20) default NULL,
`pw_clear_passwd` char(16) default NULL,
PRIMARY KEY (`pw_name`,`pw_domain`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1;

/*!40101 SET SQL_MODE=@OLD_SQL_MODE */;
/*!40014 SET FOREIGN_KEY_CHECKS=@OLD_FOREIGN_KEY_CHECKS */;
/*!40014 SET UNIQUE_CHECKS=@OLD_UNIQUE_CHECKS */;
/*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */;
/*!40101 SET CHARACTER_SET_RESULTS=@OLD_CHARACTER_SET_RESULTS */;
/*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */;
/*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */;
————————————————————————————-

Install the qmail (Most of the guys know how to install qmail so I am not covering the same on this articles.

Note – Install vpopmail with mysql auth support

Copy the /home/vpopmail backup from existing system to new system. This copies all the virtual domain information and user mail files. Please make sure all the permissions are preserving and translate userid and groupid.

Copy /var/qmail/control/ from the old server to the new server.

Copy /var/qmail/alias/ from the old server to the new server.

Copy /var/qmail/users/ from the old server to the new server.

Delete /var/qmail/users/cdb. Edit /var/qmail/users/assign and change all the userid and groupid numbers to the those that match your new system. They may already be the same, but probably not.

Now I find out the userid and groupid of vpopmail on my new system:
# id -g vpopmail
89
# id -u vpopmail
89

If not matched changed it to 89 on /var/qmail/users/assign file as vpopmail own the same uid and gid on the system

Regenerate the /var/qmail/users/cdb file from the assign file by running qmail-newu:
/var/qmail/bin/qmail-newu
Run qmailctl cdb so that tcpserver can identify /etc/tcp.smtp & /etc/tcp.pop3d
Edit /service/qmail-pop3d/run and replace ‘pop3’ with 110
Edit /service/qmail-pop3d/run and replace hostname like xxx.vmgraduate.com with domain name like vmgraduate.com

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: