<p>I am trying to backup postgres database from RDS using K8s cronjob.
I have created cronjob for it my EKS cluster and credentials are in Secrets.
When Its try to copy backup fail into AWS S3 bucket pod fails with error:
<strong>aws: error: argument command: Invalid choice, valid choices are:</strong>
I tried different options but its not working.</p>
<p>Anybody please help in resolving this issue.
Here is brief info:
K8s cluster is on AWS EKS
Db is on RDS
I am using following config for my cronjob:</p>
<pre><code>apiVersion: batch/v1beta1
kind: CronJob
metadata:
 name: postgres-backup
 spec:
  schedule: &quot;*/3 * * * *&quot;
  jobTemplate:
    spec:
      backoffLimit: 0
      template:
        spec:
          initContainers:
            - name: dump
              image: postgres:12.1-alpine
              volumeMounts:
                - name: data
                  mountPath: /backup
              args:
                - pg_dump
                - &quot;-Fc&quot;
                - &quot;-f&quot;
                - &quot;/backup/redash-postgres.pgdump&quot;
                - &quot;-Z&quot;
                - &quot;9&quot;
                - &quot;-v&quot;
                - &quot;-h&quot;
                - &quot;postgress.123456789.us-east-2.rds.amazonaws.com&quot;
                - &quot;-U&quot;
                - &quot;postgress&quot;
                - &quot;-d&quot;
                - &quot;postgress&quot;
              env:
                - name: PGPASSWORD
                  valueFrom:
                    secretKeyRef:
                      # Retrieve postgres password from a secret 
                      name: postgres
                      key: POSTGRES_PASSWORD
          containers:
            - name: save
              image: amazon/aws-cli
              volumeMounts:
                - name: data
                  mountPath: /backup
              args:
                - aws
                - &quot;--version&quot;
              envFrom:
                - secretRef:
                    # Must contain AWS_ACCESS_KEY_ID, AWS_SECRET_ACCESS_KEY, AWS_DEFAULT_REGION
                    name: s3-backup-credentials
          restartPolicy: Never
          volumes:
            - name: data
              emptyDir: {}
</code></pre>

Bilal Abbasi
<p>Try this:</p>
<pre><code>...
containers:
- name: save
  image: amazon/aws-cli
  ...
  args:
  - &quot;--version&quot;  # &lt;-- the image entrypoint already call &quot;aws&quot;, you only need to specify the arguments here.
...
</code></pre>
