Re: [HACKERS] pg_basebackup --progress output for batch execution - Mailing list pgsql-hackers

From Arthur Zakirov
Subject Re: [HACKERS] pg_basebackup --progress output for batch execution
Date
Msg-id 20171114092546.GA22221@zakirov.localdomain
Whole thread Raw
In response to Re: [HACKERS] pg_basebackup --progress output for batch execution  (Martín Marqués <martin@2ndquadrant.com>)
Responses Re: [HACKERS] pg_basebackup --progress output for batch execution  (Martín Marqués <martin@2ndquadrant.com>)
List pgsql-hackers
On Fri, Nov 10, 2017 at 10:32:23AM -0300, Martín Marqués wrote:
> An example where using isatty() might fail is if you run pg_basebackup
> from a tty but redirect the output to a file, I believe that in that
> case isatty() will return true, but it's very likely that the user
> might want batch mode output.

Sorry if I misunderstood you. I think this can happen if you redirect only standard output (stdout) to a file.
But pg_basebackup writes messages to stderr. So you need redirect stderr too:

pg_basebackup -D data -X stream -R --progress --verbose &> backup

or

pg_basebackup -D data_repl -X stream -R --progress --verbose > backup 2>&1

If you redirect stderr too then isatty() will know that message output is not tty.

-- 
Arthur Zakirov
Postgres Professional: http://www.postgrespro.com
Russian Postgres Company


pgsql-hackers by date:

Previous
From: Andres Freund
Date:
Subject: Re: [PATCH]pg_buffercache add a buffer state column, Add fuction todecode buffer state
Next
From: "Moon Insung"
Date:
Subject: RE: [HACKERS][PATCH]pg_buffercache add a buffer state column, Add fuction to decode buffer state