2

I'm trying to set up WAL archiving in Postgres 13.1 using the official docker images. I'm setting the archive_command setting on the command line in a docker compose file, but the command says 'not found' in the logs. When I run the command directly on the container everything copies fine.

Is there a way to get better logging about why it's failing?

Docker Compose file:

version: "3.8"
services:
  test_server_database:
    build:
      context: .
      dockerfile: Dockerfile-test-database
    volumes:
      - test-db:/var/lib/postgresql/data
      - test-db-creds:/root/.ssh
    environment:
      POSTGRES_USER: test
      POSTGRES_PASSWORD: 
      POSTGRES_DB: test_db
    ports:
      - 5433:5432
    command:
      - "postgres"
      - "-c"
      - "wal_level=logical"
      - "-c"
      - "archive_mode=on"
      - "-c"
      - 'archive_command="/usr/bin/scp -v -i /root/.ssh/ingest_id_rsa -pr -P 2222 -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null /var/lib/postgresql/data/%p linuxserver.io@ingest_1:/data/wal/%f"'
      - "-c"
      - 'log_min_messages=DEBUG1'
volumes:
  test-db:
  test-db-creds:

Log messages:

test_server_database_1  | sh: 1: /usr/bin/scp -v -i /root/.ssh/ingest_id_rsa -pr -P 2222 -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null /var/lib/postgresql/data/pg_wal/00000001000000000000001F linuxserver.io@ingest_1:/data/wal/00000001000000000000001F: not found
test_server_database_1  | 2021-05-07 22:02:10.196 UTC [32] FATAL:  archive command failed with exit code 127
test_server_database_1  | 2021-05-07 22:02:10.196 UTC [32] DETAIL:  The failed archive command was: "/usr/bin/scp -v -i /root/.ssh/ingest_id_rsa -pr -P 2222 -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null /var/lib/postgresql/data/pg_wal/00000001000000000000001F linuxserver.io@ingest_1:/data/wal/00000001000000000000001F"
test_server_database_1  | 2021-05-07 22:02:10.199 UTC [1] LOG:  archiver process (PID 32) exited with exit code 1
Paul Johnson
  • 1,329
  • 1
  • 12
  • 25

1 Answers1

1

My mistake was including double quotes around the command in the archive_command setting, it should be without quotes:

      - "-c"
      - 'archive_command=/usr/bin/scp -v -i /root/.ssh/ingest_id_rsa -pr -P 2222 -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null /var/lib/postgresql/data/%p linuxserver.io@ingest_1:/data/wal/%f'
Paul Johnson
  • 1,329
  • 1
  • 12
  • 25