1

Topic: Domain Staging (i.e. advance creation of users and groups)

==== REQUIRED BASIC INFO OF YOUR IREDMAIL SERVER ====
- iRedMail version (check /etc/iredmail-release): 1.3.1
- Deployed with iRedMail Easy or the downloadable installer? Installer
- Linux/BSD distribution name and version: CentOS 8 Basic
- Store mail accounts in which backend (LDAP/MySQL/PGSQL): MariaDB
- Web server (Apache or Nginx): Nginx
- Manage mail accounts with iRedAdmin-Pro? No
- [IMPORTANT] Related original log or error message is required if you're experiencing an issue.
====

This question is about moving domains over to an iRedMail server in a slow and methodical way.

Imagine I have five domains, a.com, b.com ... e.com, all handled on another email server product. I don't want to switch them all at the same time (too many support calls). So I move them one at a time.

Step 1.
- In iRedMail, set up a.com (slowly and carefully adding users, synonyms, lists, etc).
- move all the mail over using (e.g.) imapsync
- change the MX records for a.com
- tell the old server that a.com is not handled locally
- done (more or less)!

Step 2. I'm stuck!

I can't set up b.com slowly, because as soon as I create it, any email created from user1@a.com to user2@b.com is treated as a local message, and thus will fail until user2@b.com is created. Also, I'd have to telll user2 to check both email servers for messages during the transition period.

Thus my question:

Is there a way to populate a complete domain in iRedMail, while still having other domains on the same server treat it as external? That is, a.com emails need to look at b.com's MX record and see that the old server is still handling b.com email.

Does the "Enable this Domain" checkbox in the Admin Panel do this? Or does it just turn off message handling for the domain?

2

Re: Domain Staging (i.e. advance creation of users and groups)

Personally i recommend migrate all domains at the same time, a lot easier.

----

Buy me a cup of coffee ($5) to support iRedMail:

buy me a cup of coffee

3 (edited by evenmoreconfused 2021-03-31 23:57:31)

Re: Domain Staging (i.e. advance creation of users and groups)

Hmmm..... seems pretty daunting!

Five small domains are already migrated, only two big ones still remain. There are hundreds of lines in the Exchange distribution groups (what iRedMail calls lists -- using the "is_list" flag) alone.

It would be much less stressful if I could set up the user directories of these domains beforehand, and then flip a switch to "turn the domain on". From your comment, I conclude that I can't, because as soon as the domain is added in iRedMail, any messages to it from users in the domains already migrated will be treated as "on server". On the plus side, messages originating externally will keep going to the old server until the MX is changed.

I can probably manage the user adds and the mailbox migrations with a script, but the distribution groups are going to be a real issue. I'm going to try using a combination of powershell for exporting and dbeaver for importing into iRedMail.

I'll let people know how it goes...

4 (edited by evenmoreconfused 2021-04-05 23:09:36)

Re: Domain Staging (i.e. advance creation of users and groups)

So far so good. If anyone finds this later, they may be interested in the following PowerShell script that generates a CSV list of Exchange's distribution group records, suitable for importing in iRedMails's "forwardings" table (using e.g. DBeaver).

This and similar, simpler, scripts have allowed me to have the entire configuration for the domain ready and waiting for import once I create the domain in iRedMail. This way, downtime during implementation should be minutes rather than many hours.

$n = 71
$lists = Get-DistributionGroup
# *************************************** Iterate thru Distribution Groups
ForEach ($list in $lists)
{
    If (($list.PrimarySmtpAddress -Split "@")[1] -eq "mydomain.com")
    {
       $members = Get-DistributionGroupMember -Identity $list.Name
# *************************************** Iterate thru Members of Group 
       ForEach ($member in $members)
        {
            $dom = ($member.PrimarySmtpAddress -Split "@")[1]
            Write-Host ($n, $list.PrimarySmtpAddress, $member.PrimarySmtpAddress, "mydomain.com", $dom, 0, 1, 0, 0, 1) -Separator ", " 6>> distgroups.txt
            $n++
        }
    }
}

(caution: the website is breaking up long lines -- the Write-Host statement must be all one line all the way through ... distgroups.txt)


Notes:
1. You will need to replace "mydomain.com" with your own domain name in two places above. Line 6 selects only distribution groups in the domain of interest.
2. The output of the above is piped to distgroups.txt; to run a trial, remove the 6>> distgroups.txt from line 11 and it will go to the console instead.
3. The $n=71 on line 1 seeds the record counter (which is kept in column one of the forwardings table) to start at 71. Adjust to match your table.
4. PowerShell support for Exchange (2010, in my case) has to be enabled by running the following command. There's a different snap-in for later Exchange versions, but you'll have to search for it.

Add-PSsnapin Microsoft.Exchange.Management.PowerShell.E2010