<p>We deploy a laravel project in k8s(GCP) with mysql database. Now i want time to time backup of this database with the help of cronjob and I followed an <a href="https://medium.com/searce/cronjob-to-backup-mysql-on-gke-23bb706d9bbf" rel="nofollow noreferrer">articles</a>  but i'm unable to create a backup file. However, as per article we need to create the storage bucket and service account in <a href="https://support.google.com/a/answer/7378726?hl=en" rel="nofollow noreferrer">GCP</a>    </p>

<p>It is working properly still there is no backup file in storage bucket.</p>

<p>cronjob.yaml file</p>

<p><code>
apiVersion: batch/v1beta1
kind: CronJob
metadata:
  name: backup-cronjob
spec:
  schedule: "*/1 * * * *"
  jobTemplate:
    spec:
      template:
        spec:
          containers:
          - name: backup-container
            image: gcr.io/thereport/abcd
            env:
              - name: DB_NAME
                valueFrom:
                  configMapKeyRef:
                    name: backup-configmap
                    key: db
              - name: GCS_BUCKET
                valueFrom:
                  configMapKeyRef:
                    name: backup-configmap
                    key: gcs-bucket
              - name: DB_HOST
                valueFrom:
                  secretKeyRef:
                    name: backup
                    key: db_host
              - name: DB_USER
                valueFrom:
                  secretKeyRef:
                    name: backup
                    key: username
              - name: DB_PASS
                valueFrom:
                  secretKeyRef:
                    name: backup
                    key: password
              - name: GCS_SA
                valueFrom:
                  secretKeyRef:
                    name: backup
                    key: thereport-541be75e66dd.json
            args:
            - /bin/bash
            - -c
            - mysqldump --u root --p"root" homestead > trydata.sql; gcloud config set project thereport; gcloud auth activate-service-account --key-file backup; gsutil cp /trydata.sql gs://backup-buck</p>

<pre><code>      restartPolicy: OnFailure
</code></pre>

<p></code> </p>

<p>You don't copy the right file:</p>

<blockquote>
  <p>mysqldump --u root --p"root" homestead > <strong>trydata.sql</strong>; gcloud config set project thereport; gcloud auth activate-service-account --key-file backup; gsutil cp <strong>/laravel.sql</strong> gs://backup-buck</p>
</blockquote>
