apiVersion: batch/v1beta1
kind: CronJob
metadata:
  name: backupdb
  annotations:
    linkerd.io/inject: disabled
spec:
  schedule: '0 */4 * * *'
  jobTemplate:
    spec:
      template:
        metadata:
          annotations:
            linkerd.io/inject: disabled
        spec:
          containers:
            - name: dbbackup
              image: 'postgres:13.4'
              imagePullPolicy: IfNotPresent
              env:
                - name: PGPASSWORD
                  value: direktivdirektiv # change pwd here and add additional commands. the example is bad btw :)
              command:
                - /bin/sh
                - '-c'
                - >-
                  date; echo "backup start";
                  /usr/bin/pg_dump -d direktiv -h
                  postgres-postgresql-ha-pgpool.postgres -f /tmp/data.sql -U direktiv; ls -la /tmp;
                  apt-get update; apt install -y sshpass;
                  sshpass -p "pwd" scp -o StrictHostKeyChecking=no /tmp/data.sql username@192.168.1.10:/tmp/data.sql;
                  echo "copied"
          restartPolicy: Never
