apiVersion: batch/v1
kind: Job
metadata:
  name: xtrabackup-restore-job
spec:
  template:
    spec:
      containers:
      - name: xtrabackup
        image: perconalab/backupjob-openshift
        command:
        - bash
        - "-c"
        - |
          set -ex
          cd /datadir
          rm -fr *
          cat /backup/$BACKUPSRC/xtrabackup.stream | xbstream -x 
          xtrabackup --prepare --target-dir=/datadir
        env:
          - name: BACKUPSRC
            value: "cluster1-node-0.cluster1-nodes-2018-06-18-17-26"
        volumeMounts:
        - name: backup
          mountPath: /backup
        - name: datadir
          mountPath: /datadir
      restartPolicy: Never
      volumes:
      - name: backup
        persistentVolumeClaim:
          claimName: backup-volume
      - name: datadir
        persistentVolumeClaim:
          claimName: datadir-cluster1-node-0
  backoffLimit: 4
