apiVersion: batch/v1
kind: Job
metadata:
  labels:
    application: spilo-logical-backup
    job-name: restore
  name: restore
spec:
  backoffLimit: 6
  completions: 1
  parallelism: 1
  selector:
    matchLabels:
      job-name: restore
  template:
    metadata:
      creationTimestamp: null
      labels:
        application: spilo-logical-backup
        job-name: restore
    spec:
      containers:
      - command:
        - /bin/sh
        - -c
        args:
        - aws s3 cp s3://${NS}-dumps/migrations/$(date +%m-%d-%Y).sql.gz - --endpoint-url=https://minio.k7.indie.host --region=default | unpigz | pg_restore -d hedgedoc -h pg-${NS} -p 5432 -U hedgedoc --clean --no-owner --role=hedgedoc
        env:
        - name: PGPASSWORD
          valueFrom:
            secretKeyRef:
              key: password
              name: hedgedoc.pg-${NS}.credentials
        - 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