Unable to create a MySQL database backup in GCP storage

10/17/2019

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 articles but i'm unable to create a backup file. However, as per article we need to create the storage bucket and service account in GCP

It is working properly still there is no backup file in storage bucket.

cronjob.yaml file

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

``` restartPolicy: OnFailure ```

-- saaya kasta
devops
google-cloud-platform
kubernetes
kubernetes-cronjob
mysql

1 Answer

10/17/2019

You don't copy the right file:

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

-- guillaume blaquiere
Source: StackOverflow