How to setup a mailbox clone

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
6 messages Options
Reply | Threaded
Open this post in threaded view
|

How to setup a mailbox clone

Paul Richards
I understand how a MX relay works and how to implement it in postfix, but what I am looking to do is create a clone of all the mailboxes on our system to another system. So is one server setup like a MX backup relay and then there is some switch or option that I don't know or do I just setup 'virtual_alias_maps' in main.cf on both systems to save a copy of the email and forward it to the other? Will postfix be smart enough not to get stuck in a loop?

Can I just use:
#in /etc/postfix/main.cf
virtual_alias_maps = hash:/etc/postfix/domain_copy.conf

#in /etc/postfix/domain_copy.conf
Thanks,

Paul Richards
Reply | Threaded
Open this post in threaded view
|

Re: How to setup a mailbox clone

Wietse Venema
You appear to describe a system that delivers mail to two independent
message stores. The problem with that approach is that if a user
reads or deletes a message on one message store, then their action
will not change the state of the other message store.

It is possible to do better than that.

If you need a consistent view of multiple message stores, then you
need a replicated message store. Dovecot supports asynchronous
replication between a pair of master servers. You configure Postfix
to deliver mail to one of the two Dovecot instances (e.g., using
one DNS name with two A records, or random hostname selection with
the Postfix randmap feature), and the Dovecot instances talk to
each other. When one Dovecot instance is down, Postfix will deliver
to the instance that is available.

> I understand how a MX relay works and how to implement it in postfix, but
> what I am looking to do is create a clone of all the mailboxes on our
> system to another system. So is one server setup like a MX backup relay and
> then there is some switch or option that I don't know or do I just setup
> 'virtual_alias_maps' in main.cf on both systems to save a copy of the email
> and forward it to the other? Will postfix be smart enough not to get stuck
> in a loop?

Two-way forwarding between MTAs is the definition of a mail forwarding
loop. Postfix breaks loops by looking at the hopcount_limit and at
Delivered_To: headers, and that results in a non-delivery notification
to the sender. So don't do that.

        Wietse
Reply | Threaded
Open this post in threaded view
|

Re: How to setup a mailbox clone

Viktor Dukhovni
In reply to this post by Paul Richards


> On May 18, 2018, at 11:03 AM, Paul Richards <[hidden email]> wrote:
>
> #in /etc/postfix/domain_copy.conf
> @mydomain.edu @host1.mydomain.edu @host2.mydomain.edu

This sort-of-works provided each host does not forward
mail for @<thishost>.mydomain.edu to the other, but
breaks recipient validation if implemented as a wildcard.
Avoid wildcard virtual alias maps.

More importantly of course, per Wietse's note the semantics
of duplicate delivery are unfortunate, so replicate at the
mailstore level.

--
        Viktor.

Reply | Threaded
Open this post in threaded view
|

Re: How to setup a mailbox clone

Wietse Venema
In reply to this post by Paul Richards
Paul Richards:
> Can I just use:
> #in /etc/postfix/main.cf
> virtual_alias_maps = hash:/etc/postfix/domain_copy.conf
>
> #in /etc/postfix/domain_copy.conf
> @mydomain.edu @host1.mydomain.edu @host2.mydomain.edu

This should not loop, because you are not sending @host1.mydomain.edu
to @host2.mydomain.edu or vice versa.

However, the use of wildcards breaks address validation. See today's
email thread "Problem with virtual_alias_maps and backscatter" for
possible remediation.

That said, I think that the replicated message store would be the
better approach because the replication enforces consistency.

        Wietse
Reply | Threaded
Open this post in threaded view
|

Re: How to setup a mailbox clone

@lbutlr
On 20 May 2018, at 09:23, Wietse Venema <[hidden email]> wrote:
> That said, I think that the replicated message store would be the
> better approach because the replication enforces consistency.

This thread is starting to feel like one of those "I want to do X but I don’t want to do (Thing specifically designed to do X) and instead want to do (something I thought up that I want to work). Can anyone help me” threads.

--
I'm not old, I'm chronologically challenged.
Reply | Threaded
Open this post in threaded view
|

Re: How to setup a mailbox clone

Paul Richards
In reply to this post by Wietse Venema
Thanks, I am running dovecot as well and did not realize it could do that! I will do it that way!

I appreciate everyone else's help as well!

Best Regards,

Paul Richards
Code Monkey/System Admin

On Sat, May 19, 2018 at 12:26 PM, Wietse Venema <[hidden email]> wrote:
You appear to describe a system that delivers mail to two independent
message stores. The problem with that approach is that if a user
reads or deletes a message on one message store, then their action
will not change the state of the other message store.

It is possible to do better than that.

If you need a consistent view of multiple message stores, then you
need a replicated message store. Dovecot supports asynchronous
replication between a pair of master servers. You configure Postfix
to deliver mail to one of the two Dovecot instances (e.g., using
one DNS name with two A records, or random hostname selection with
the Postfix randmap feature), and the Dovecot instances talk to
each other. When one Dovecot instance is down, Postfix will deliver
to the instance that is available.

> I understand how a MX relay works and how to implement it in postfix, but
> what I am looking to do is create a clone of all the mailboxes on our
> system to another system. So is one server setup like a MX backup relay and
> then there is some switch or option that I don't know or do I just setup
> 'virtual_alias_maps' in main.cf on both systems to save a copy of the email
> and forward it to the other? Will postfix be smart enough not to get stuck
> in a loop?

Two-way forwarding between MTAs is the definition of a mail forwarding
loop. Postfix breaks loops by looking at the hopcount_limit and at
Delivered_To: headers, and that results in a non-delivery notification
to the sender. So don't do that.

        Wietse