PostgreSQL backup issue

Started by Jayadevan Malmost 8 years ago4 messagesgeneral
Jump to latest
#1Jayadevan M
maymala.jayadevan@gmail.com

Hello all,

I have a PostgreSQL backup script which executes daily. The backup creates
no output on "some" days - no pattern observed yet. There is no space
issue.
Here are the relevant lines from the shell script.

mkdir $bdir
echo "Backup began at " `date` | tee -a $logfile
pg_basebackup --checkpoint=fast --xlog-method=fetch -v -P -h xx.xxx.xx.xx
-U replication -R -D $bdir | tee -a $logfile
echo "Backup completed at " `date` | tee -a $logfile

The directory $bdir does get created. But it remains empty. The echo before
and after the backup is writing to $logfile.
Everything that happens on the database gets logged in PGLOG file. Even the
connection request by replication user is not there in PGLOG file on the
days when the backup doesn't work. Best way to trouble-shoot this? Also,
the output from pg_basebackup does not get logged in $logfile even on those
days when the backup works fine. How can I get the output into the logfile?

Regards,
Jayadevan

#2David G. Johnston
david.g.johnston@gmail.com
In reply to: Jayadevan M (#1)
Re: PostgreSQL backup issue

On Tuesday, May 22, 2018, Jayadevan M <maymala.jayadevan@gmail.com> wrote:

pg_basebackup ... | tee -- Also, the output from pg_basebackup does not
get logged in $logfile even on those days when the backup works fine.

I would conclude that pg-basebackup is placing its output in stderr instead
of stdout then...

David J.

#3Michael Paquier
michael@paquier.xyz
In reply to: David G. Johnston (#2)
Re: PostgreSQL backup issue

On Tue, May 22, 2018 at 10:35:46PM -0700, David G. Johnston wrote:

I would conclude that pg-basebackup is placing its output in stderr instead
of stdout then...

The output of pg_basebackup's verbose mode goes to stderr (look for
example at the verbose flags in pg_basebackup.c).
--
Michael

#4Jayadevan M
maymala.jayadevan@gmail.com
In reply to: David G. Johnston (#2)
Re: PostgreSQL backup issue

I would conclude that pg-basebackup is placing its output in stderr
instead of stdout then...

Thanks. Modifying the last potion to '>>$logfile 2>&1' worked.

Regards,
Jayadevan