Re: archive_command fails but works outside of Postgres

From: Mark Watson <mark(dot)watson(at)jurisconcept(dot)ca>
To: twoflower <standa(dot)kurik(at)gmail(dot)com>, "pgsql-general(at)postgresql(dot)org" <pgsql-general(at)postgresql(dot)org>
Subject: Re: archive_command fails but works outside of Postgres
Date: 2017-08-18 19:46:34
Message-ID: 02F1BBB48ABD3245A3BC519B57CFC8CA018C8FC2C8@Exchange.JurisConcept.local
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

De : pgsql-general-owner(at)postgresql(dot)org [mailto:pgsql-general-owner(at)postgresql(dot)org] De la part de twoflower
Envoyé : Friday, August 18, 2017 2:40 PM
À : pgsql-general(at)postgresql(dot)org
Objet : [GENERAL] archive_command fails but works outside of Postgres

I changed my archive_command to the following:

archive_command = 'gsutil cp /storage/postgresql/9.6/main/%p gs://my_bucket/pg_xlog/'
and it fails, leaving the following in the log:

2017-08-18 18:34:25.057 GMT [1436][0]: [104319] LOG: archive command failed with exit code 1

2017-08-18 18:34:25.057 GMT [1436][0]: [104320] DETAIL: The failed archive command was: gsutil cp /storage/postgresql/9.6/main/000000010000038B000000D8 gs://my_bucket/pg_xlog/

2017-08-18 18:34:25.057 GMT [1436][0]: [104321] WARNING: archiving transaction log file "000000010000038B000000D8" failed too many times, will try again later

But the command works when executed manually:

root$ su postgres -c "gsutil cp /storage/postgresql/9.6/main/000000010000038B000000D8 gs://my_bucket/pg_xlog/"

root$ echo $?

0
The last command verifies that gsutil indeed exited with 0.

How to best debug this issue?

I think the parameter %p contains the complete path of the file and that you may need to specify the file name for the destination. Try this for your archive command :
archive_command = 'gsutil cp "%p" "gs://my_bucket/pg_xlog/%f"'

- Mark Watson

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Vincenzo Romano 2017-08-18 19:59:50 Re: Results interpretation
Previous Message Alvaro Herrera 2017-08-18 19:45:11 Re: archive_command fails but works outside of Postgres