apiVersion: batch/v1
kind: Job
metadata:
  labels:
    application: spilo-logical-backup
    job-name: dump
  name: dump
spec:
  backoffLimit: 6
  completions: 1
  parallelism: 1
  selector:
    matchLabels:
      job-name: dump
  template:
    metadata:
      creationTimestamp: null
      labels:
        application: spilo-logical-backup
        job-name: dump
    spec:
      containers:
      - command:
        - /bin/sh
        - -c
        args:
        - psql -h ${FQDN}-postgresql -p 5432 -U codimd -c "\l";
        - pg_dump -h ${FQDN}-postgresql -p 5432 -U codimd -Fc codimd | pigz | aws s3 cp - s3://${NS}-dumps/migrations/$(date +%m-%d-%Y).sql.gz --endpoint-url=https://minio.k7.indie.host --region=default
        env:
        - name: PGPASSWORD
          valueFrom:
            secretKeyRef:
              key: postgresql-password
              name: ${FQDN}
        - name: AWS_S3_FORCE_PATH_STYLE
          value: "true"
        envFrom:
        - secretRef:
            name: ${NS}-dumps
        image: registry.opensource.zalan.do/acid/logical-backup:v1.6.2
        imagePullPolicy: IfNotPresent
        name: logical-backup
      restartPolicy: Never