Temporarily stop mail delivery

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

Temporarily stop mail delivery

Martin Brampton
Is there a simple way to temporarily stop postfix delivering mail into the /var/vmail mail boxes, instead queueing them up? The purpose being to get a clean backup of /var/vmail without stopping receipt of mail from the internet. Then restart mail delivery so the queue is emptied into the appropriate local mail boxes?

Martin
Reply | Threaded
Open this post in threaded view
|

Re: Temporarily stop mail delivery

Ralph Seichter
On 25.12.2017 11:14, Black Sheep wrote:

> Is there a simple way to temporarily stop postfix delivering mail into
> the /var/vmail mail boxes [...]

The following method works (I'm not certain if reloading is even
required):

#!/bin/bash
# Temporarily disable local delivery
postconf -e defer_transports=local && postfix reload
[... Your backup operations here ...]
# Re-enable local delivery
postconf -e defer_transports='' && postfix reload

-Ralph
Reply | Threaded
Open this post in threaded view
|

Re: Temporarily stop mail delivery

Martin Brampton
Thanks, looks good. I’d think the reload probably is necessary.

Martin

On 25 Dec 2017, 10:30 +0000, Ralph Seichter <[hidden email]>, wrote:
On 25.12.2017 11:14, Black Sheep wrote:

Is there a simple way to temporarily stop postfix delivering mail into
the /var/vmail mail boxes [...]

The following method works (I'm not certain if reloading is even
required):

#!/bin/bash
# Temporarily disable local delivery
postconf -e defer_transports=local && postfix reload
[... Your backup operations here ...]
# Re-enable local delivery
postconf -e defer_transports='' && postfix reload

-Ralph
Reply | Threaded
Open this post in threaded view
|

Re: Temporarily stop mail delivery

Wietse Venema
In reply to this post by Martin Brampton
Black Sheep:
> Is there a simple way to temporarily stop postfix delivering mail
> into the /var/vmail mail boxes, instead queueing them up? The
> purpose being to get a clean backup of /var/vmail without stopping
> receipt of mail from the internet. Then restart mail delivery so
> the queue is emptied into the appropriate local mail boxes?

/etc/postfix/main.cf
    transport_maps = static:{4.3.0 Mail service unavailable}

That will stop Postfix from acccepting mail from the network.

        Wietse
Reply | Threaded
Open this post in threaded view
|

Re: Temporarily stop mail delivery

Anvar Kuchkartaev
In reply to this post by Martin Brampton
Before taking backup or other action that requires stopping mail delivery I usually just stop all postfix instances which MX record points.

Anvar Kuchkartaev 
[hidden email]
From: Black Sheep
Sent: lunes, 25 de diciembre de 2017 11:14
To: Postfix users‎
Subject: Temporarily stop mail delivery

Is there a simple way to temporarily stop postfix delivering mail into the /var/vmail mail boxes, instead queueing them up? The purpose being to get a clean backup of /var/vmail without stopping receipt of mail from the internet. Then restart mail delivery so the queue is emptied into the appropriate local mail boxes?

Martin

Reply | Threaded
Open this post in threaded view
|

Re: Temporarily stop mail delivery

Viktor Dukhovni
In reply to this post by Martin Brampton


> On Dec 25, 2017, at 5:14 AM, Black Sheep <[hidden email]> wrote:
>
> Is there a simple way to temporarily stop postfix delivering mail into the /var/vmail mail boxes, instead queueing them up? The purpose being to get a clean backup of /var/vmail without stopping receipt of mail from the internet. Then restart mail delivery so the queue is emptied into the appropriate local mail boxes?


http://www.postfix.org/postconf.5.html#defer_transports

   # Defer delivery via all transports that store mail locally,
   # "smtp" and "relay" delivery mail to remote systems and can
   # continue.  Add or remove elements to match what's used from
   # master.cf
   #
   defer_transports = local, virtual, lmtp, maildrop

changing this requires a "reload".

--
        Viktor.

Reply | Threaded
Open this post in threaded view
|

Re: Temporarily stop mail delivery

Wietse Venema
In reply to this post by Wietse Venema
Wietse Venema:
> Black Sheep:
> > Is there a simple way to temporarily stop postfix delivering mail
> > into the /var/vmail mail boxes, instead queueing them up? The
> > purpose being to get a clean backup of /var/vmail without stopping
> > receipt of mail from the internet. Then restart mail delivery so
> > the queue is emptied into the appropriate local mail boxes?
>
> /etc/postfix/main.cf
>     transport_maps = static:{4.3.0 Mail service unavailable}

Sorry that should be:

        transport_maps = static:{retry:4.3.0 Mail service unavailable}

> That will stop Postfix from acccepting mail from the network.
>
> Wietse
>
Reply | Threaded
Open this post in threaded view
|

Re: Temporarily stop mail delivery

Philip Paeps
On 2017-12-25 13:58:53 (-0500), Wietse Venema wrote:

>Wietse Venema:
>> Black Sheep:
>> > Is there a simple way to temporarily stop postfix delivering mail
>> > into the /var/vmail mail boxes, instead queueing them up? The
>> > purpose being to get a clean backup of /var/vmail without stopping
>> > receipt of mail from the internet. Then restart mail delivery so
>> > the queue is emptied into the appropriate local mail boxes?
>>
>> /etc/postfix/main.cf
>>     transport_maps = static:{4.3.0 Mail service unavailable}
>
>Sorry that should be:
>
> transport_maps = static:{retry:4.3.0 Mail service unavailable}
>
>> That will stop Postfix from acccepting mail from the network.

Oh wow.  Thanks for that tip!

I really need to get used to start using more of these static: maps.  I
have a couple single-entry /^.*$/ pcre: tables which should probably all
be static:.

Philip

--
Philip Paeps
Senior Reality Engineer
Ministry of Information
Reply | Threaded
Open this post in threaded view
|

Re: Temporarily stop mail delivery

Dominic Raferd
In reply to this post by Martin Brampton
On 25/12/2017 10:14, Black Sheep wrote:
> Is there a simple way to temporarily stop postfix delivering mail into
> the /var/vmail mail boxes, instead queueing them up? The purpose being
> to get a clean backup of /var/vmail without stopping receipt of mail
> from the internet. Then restart mail delivery so the queue is emptied
> into the appropriate local mail boxes?
Backing up each file via postlock works well with mbox-style mail boxes,
I don't know if it is practical with maildir. No need to modify postfix
configuration files or to reload postfix.
Reply | Threaded
Open this post in threaded view
|

Re: Temporarily stop mail delivery

Dominic Raferd
On 26 December 2017 at 11:02, Neil Sotheby <[hidden email]> wrote:
>
> That's a good idea but would it stop the acceptance of new incoming messages?
> ...

An expert can answer, but it would be bizarre behaviour if true. I
rather assume that postfix continues to accept incoming mails, and
queues any that are destined for the locked local file until postlock
releases its exclusive lock.
Reply | Threaded
Open this post in threaded view
|

Re: Temporarily stop mail delivery

Viktor Dukhovni


> On Dec 26, 2017, at 6:52 AM, Dominic Raferd <[hidden email]> wrote:
>
> An expert can answer, but it would be bizarre behaviour if true. I
> rather assume that postfix continues to accept incoming mails, and
> queues any that are destined for the locked local file until postlock
> releases its exclusive lock.

Inbound mail continues, some local(8) deliveries may be briefly delayed
waiting for a lock, all other deliveries will continue.  The locks should
be held very briefly, just long enough to copy each file.  Attempts to
lock multiple files can deadlock (though not with Postfix delivery agents
which do not lock multiple files).  Lock a file, back it up promptly,
release that file's lock and move on to the next.

--
        Viktor.