Setting Up Zimbra and Backup
Setting Up Zimbra and Backup
0 PROJECT OVERVIEW
Server Setup
A Zimbra mail server carrying out the functions of receiving mail for organizational users as
well as enabling them send out mail messages.
Samba domain set up to add users and authenticate them against credentials stored in the
server.
A central LDAP server to store user information and provide authentication for the above 2
services and any other services that may be require these.
Insert your CentOS 5.1 install CD into your system and boot from it. Hit Enter to start the installation.
Enter the default settings till the Network Devices part. Network Devices gives you the opportunity to enter IP
address information for your network. Keep in mind that you cannot run an email server using DHCP. Use the
edit button and enter information appropriate for your network. Don't forget to enter your gateway and
nameservers as well.
Then follow the remaining steps using the default setting. Enter a root password for the system. Then you will be
prompted to choose the packages to install. Choose the packages to install. Uncheck all boxes in the upper pane
and check the box for the CentOS Extra Packages in the lower pane. Click the radio button for Customize Now
and click Next. As shown in the image below then click next:
A box will pop up verifying your IP address information. The next screen allows you to choose packages for
your installation. You should the following packages:
Applications
Editors
Text-based Internet
Development
Development Libraries
Development Tools
Legacy Software Development
Base System
Base
Legacy Software Support
and ensure that gcc and perl are installed plus all the other packages.
Start the installation and reboot once the installation has ended.
Once the system reboots you are presented with the firstboot screen to put in your necessary details. You will be
prompted to enable the firewall and SELinux. You should disable this since it will bring problems to the Zimbra
installation. This should be in a computer thats behind a firewall less it will cause security issues.
NB: But will enable the firewall later to allow only specific ports that are to be used by Zimbra.
The system will reboot and load the login screen. Once logged in you are to disable the loading of the following
services iptables, ip6tables and sendmail :-
chkconfig sendmail off
chkconfig ip6tables off
chkconfig iptables off
Cancel the update of the entire system. This might take some time depending on the internet speeds but is
necessary in my experience. It helps ensure that the above selected packages are the latest and helps correct
some instabilities that are inherent in CentOS 5.1
We need one package before we can continue:
yum install libtool-ltdl and update perl
yum install perl
On the next page we will setup Split DNS which is essential for ZCS
This part of installation is working off of the assumption that you are behind a firewall. If you are not
behind a firewall (not recommended) you can skip this part of the installation.
REMINDER: Be sure to use the ip address and hostname/FQDN that is appropriate for your
installation.
vim /var/named/chroot/etc/named.conf
options {
directory "/var/named";
dump-file "/var/named/data/cache_dump.db";
statistics-file "/var/named/data/named_stats.txt";
forwarders { 212.49.70.11 ; 212.49.70.12; 212.49.70.23 };
};
include "/etc/rndc.key";
// We are the master server for openworld.co.ke
zone "openworld.co.ke" {
type master;
file "db.openworld.co.ke";
};
The ip address for forwarders should be the ip address of your dns server.
vim /var/named/chroot/var/named/db.openworld.co.ke
;
; Addresses and other host information.
;
@ IN SOA openworld.co.ke. hostmaster.openworld.co.ke. (
10118 ; Serial
43200 ; Refresh
3600 ; Retry
3600000 ; Expire
2592000 ) ; Minimum
; Define the nameservers and the mail servers
IN NS 192.168.111.113
IN A 192.168.111.113
IN MX 10 openworld.co.ke.
Change your resolv.conf to use your mail server's IP address as it's primary DNS.
vim /etc/resolv.conf
search openworld.co.ke
nameserver 192.168.111.113
/etc/init.d/named start
chkconfig named on
nslookup openworld.co.ke
Server: 192.168.111.113
Address: 192.168.111.113#53
Name: openworld.co.ke
Address: 192.168.111.113
Notice that the ip address returned is the same as the local machine. That means success.
Configure openLDAP
search for the samba schema of your samba installation
copy the samba schema to openldap
cp /usr/share/doc/samba-3.0.28/LDAP/samba.schema /opt/zimbra/openldap/etc/openldap/schema/
nis.schema already exists in /opt/zimbra/openldap/etc/openldap/schema/ for ZCS-5.*
edit slapd.conf.in - [/opt/zimbra/conf/slapd.conf.in] (not slapd.conf as changes for it are read from slapd.conf.in
and effected when zimbra server is restart)
add these lines where other schema are defined
include "/opt/zimbra/openldap/etc/openldap/schema/nis.schema"
include "/opt/zimbra/openldap/etc/openldap/schema/samba.schema"
Add these after all the other indexes
#indexes for PAM
index uidNumber eq
index gidNumber eq
index memberUID eq
after copying schema and editing slapd.conf.in restart zimbra (zmcontrol stop then zmcontrol start)and run this
command as user zimbra (su - zimbra)
NB: Ensure that you have only three accounts (amavisAccount, posixAccount, sambaSamAccount). It you have
a sambaAccount, remove it since it will cause problems in creating a user.
To check available accounts - /opt/zimbra/bin/zmprov gacf | grep zimbraAccountExtraObjectClass
To remove the sambaAccount - zmprov mcf -zimbraAccountExtraObjectClass sambaAccount
3. SYSTEM TESTING
Test the Server
Go back to the Zimbra admin UI. Go to Posix Groups, click the tab for Samba and select the Samba domain
name from the drop down menu. Once you save the Samba domain in the Posix group, then you click “New”. If
you do not know what to type in group type field – type 2, this is the default value.
To test if PAM on your Samba server is reading the group information correctly from Zimbra LDAP, go back to
your Samba server shell and run this command as root:
getent group
you should see the group(s) that you just created in the list that is produced.
Back to the Zimbra Admin UI:). Go to Accounts and hit New, fill in the information on the first screen and
follow the wizard to the Posix Account screen. Fill in all the required fields on the Posix Account screen and
click Next to go to Samba Account screen. To test if PAM on your Samba server is reading the user password
information correctly from Zimbra LDAP, go back to your Samba server shell and run this command as root:
getent passwd
you should see the Zimbra accounts that you just created in the list
Create a home folder for the new Zimbra user and try to change the current user to the newly created one. In this
example, I create a user usertest, and home folder /home/usertest
su - usertest
Now test if Samba authenticates your new user correctly. Got to the shell on my Zimbra server box and ran this
command as root:
smbclient -U usertest //openworld.co.ke/usertest
It should prompt you for the password and then log in to ubuntu2's home folder on aphrc.orgSamba server.
Next, log in to Zimbra Admin UI, click on Aliases and remove [email protected] alias. Then run
smbpasswd -a root
To add posixAccount attributes to the previously established users (before ldap schema change) you can run
command:
Create “admins” group using Zimbra Admin UI, on Samba tab select Special Windows group type “Domain
Admins”. Then you need to grant privileges to this group. Run the following command as root on your Samba
server.
Log in to an Windows desktop as a local administrator and join the Samba domain. Use a member of “Domain
Admins” group to join the domain. After you joined the domain, verify that the machine account was added to
ldap directory.
4. MIGRATION
Samba accounts Migration
Referring to this...
must be identical
domain SID
Run the command on your current server
net getlocalsid
Copy this value, go to the zimbra samba admin UI and edit the APHRC domain SID value by copying this value
there
user & machine RIDs
Taken care of when joining machine to domain or transferring the mail accounts
machine account password hashes
logon scripts (drive assignments)
Mail migration
Transfer/Create the users
Obtain the list of usernames and passwords from Qmail by going to the server's vqamin interface
http://IP_of_qmail_server/cgi-bin/vqadmin/vqadmin.cgi
Here, you will be prompted for an admin password. For the username, enter the name within the prompt. The
system/network administrator that setup the server should be having this.
Upon successful login, you can then view the current usernames and passwords in the system together with the
respective names by specifying a particular domain. Use these to create a list in this fashion
test:test123:Test Account
amaina:hispsswd:Antony Maina
athithu:herpsswd:Alice Thith u
give this file a name. e.g. psswd_name
Go to the Zimbra wiki in a page with a heading User Migration and copy a Perl script to create Zimbra Accounts
using the above data. Modify it to fit the current scenario's need. I have included my modified script in the
containing folder under the name passwd2zmprov. To run the script with the data from psswd_name run the
command as root
perl passwd2zmprov -domain aphrc.org < psswd_name > create_users.zmp
the output file create_users.zmp contains commands that zimbra can take in and process such as
ca "[email protected]" "hispasswd" uidNumber "10017" gidNumber "10009" givenName "Antony" sn "Maina"
cn "amaina" displayName "Antony Maina" loginShell "/bin/bash/" sambaSID "S-1-5-21-2015017091-
1876940603-389962325-21034" homeDirectory "/home/amaina" zimbraNotes "Migrated Thu Aug 7 19:57:11
2008" zimbraPasswordMustChange FALSE
to create zimbra users, run this command as user zimbra
zmprov < create_users.zmp
Go to the zimbra admin UI, click on accounts and you should see a list of user accounts created using the above
command.
Transfer the mail
To migrate the email contents copy a batch-migrate script in the above mentioned source and modify it to suit
the current scenario. Find the perl script that I used in the containing folder; batch_process. This file requires as
input a userlist.txt file that contains mail account usernames and passwords in this fashion
user1:password1
user2:password2
Run as root
perl batch_process
This should transfer mail from the current server to the new one.
Mail Transfer
Install imapsync using the following script
#!/bin/bash
#CopyLeft 2006 Steve Fink
#stevef-at-ublug.org
#This script will get all of the necessary packages to build imapsync 1.219 except OpenSSL
#OpenSSL & it's development libraries are required and OpenSSL is usually installed already so check and get the matching libraries
#you have to run this script as root or under sudo so it can do all the installs I don't recommend doing the extended tests they mostly fail
anyway but imapsync still works
mkdir imapsync
cd imapsync
wget http://search.cpan.org/CPAN/authors/id/D/DC/DCONWAY/Parse-RecDescent-1.94.tar.gz
tar xvfpz Parse-RecDescent-1.94.tar.gz
rm Parse-RecDescent-1.94.tar.gz
cd Parse-RecDescent-1.94/
perl Makefile.PL
make
make install
#
cd ..
wget http://search.cpan.org/CPAN/authors/id/G/GA/GAAS/Digest-MD5-2.33.tar.gz
tar xvfpz Digest-MD5-2.33.tar.gz
rm Digest-MD5-2.33.tar.gz
cd Digest-MD5-2.33/
perl Makefile.PL
make
make install
#
cd ..
wget http://search.cpan.org/CPAN/authors/id/J/JS/JSTOWE/TermReadKey-2.30.tar.gz
tar xvfpz TermReadKey-2.30.tar.gz
rm TermReadKey-2.30.tar.gz
cd TermReadKey-2.30/
perl Makefile.PL
make
make install
#
cd ..
wget http://search.cpan.org/CPAN/authors/id/A/AS/ASPA/IO-Socket-SSL-0.81.tar.gz
tar xvfpz IO-Socket-SSL-0.81.tar.gz
rm IO-Socket-SSL-0.81.tar.gz
cd IO-Socket-SSL-0.81/
perl Makefile.PL
make
make install
#
cd ..
wget http://search.cpan.org/CPAN/authors/id/F/FL/FLORA/Net_SSLeay.pm-1.30.tar.gz
tar xvfpz Net_SSLeay.pm-1.30.tar.gz
rm Net_SSLeay.pm-1.30.tar.gz
cd Net_SSLeay.pm-1.30/
./Makefile.PL -t
make install
#
cd ..
wget http://search.cpan.org/CPAN/authors/id/D/DJ/DJKERNEN/Mail-IMAPClient-2.2.9.tar.gz
tar xvfpz Mail-IMAPClient-2.2.9.tar.gz
rm Mail-IMAPClient-2.2.9.tar.gz
cd Mail-IMAPClient-2.2.9/
perl Makefile.PL
make
make test
make install
#
cd ..
wget http://www.linux-france.org/prj/imapsync/dist/imapsync-1.219.tgz
tar xvfpz imapsync-1.219.tgz
rm imapsync-1.219.tgz
cd imapsync-1.219/
perl -c imapsync
make install
#
cd ..
cd ..
rm -Rf imapsync/
then run the following command after installation to synchronize mail from the two servers
imapsync --host1 mail.itura.net --user1 [email protected] --password1 kevin --host2 linuxbox.bimsoft.co.ke --
user2 [email protected] --password2 daddida24 --noauthmd5