Re: pg_basebackup exit codes

From: Magnus Hagander <magnus(at)hagander(dot)net>
To: John Donath <John(dot)Donath(at)detron(dot)nl>
Cc: "pgsql-general(at)lists(dot)postgresql(dot)org" <pgsql-general(at)lists(dot)postgresql(dot)org>
Subject: Re: pg_basebackup exit codes
Date: 2019-08-19 11:45:58
Message-ID: CABUevEwauKzS-tb_ho-wcjWRq2iW5K=Z_=2C4C--aXMEioj8Qw@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

On Mon, Aug 19, 2019 at 12:18 PM John Donath <John(dot)Donath(at)detron(dot)nl> wrote:

> Hi,
>
>
>
> I was unpleasantly surprised to see that pg_basebackup will return a zero
> (Success) exit code even when it has actually failed like below:
>
>
>
> pg_basebackup: could not write to compressed file
> "/var/lib/pgsql/10/inst1/backup/cust-pg02_inst1_Fri_20190816/base.tar.gz":
> No space left on device
>
> pg_basebackup: removing data directory
> "/var/lib/pgsql/10/inst1/backup/cust-pg02_inst1_Fri_20190816"
>
>
>
> A reliable exit code is of great importance in backup scripts using a
> statement like below:
>
>
>
> pg_basebackup -D ${backup_dest} -Ft -z 2>&1 | tee -a ${log_file}; rv=$?
>
> [ $rv -eq 0 ] || error "pg_basebackup failed with rcode $rv; also see
> ${log_file}"
>
>
>
> Pg_basebackup version: (PostgreSQL) 10.10
>
>
>
> Anybody else encountering this problem?
>
>
>

I think your problem is that you are looking at the exit code from "tee"
and not from pg_basebackup. If you are using bash, you can look at
something like $PIPESTATUS to get the exit code from the actual comman
dbefore the pipe. Or you can try removing the tee command to verify if this
is indeed where the problem is coming from.

--
Magnus Hagander
Me: https://www.hagander.net/ <http://www.hagander.net/>
Work: https://www.redpill-linpro.com/ <http://www.redpill-linpro.com/>

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message John Donath 2019-08-19 12:19:54 RE: pg_basebackup exit codes
Previous Message Ron 2019-08-19 11:01:08 Re: postmaster utilization