2

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

1
  • Hello, do your kube service account have access to write objects in your bucket? for a quick try (not for real implementation) make your bucket public and try to run the job, if you see the dump file in your bucket after this you will need to take a look at your bucket policy to give access to your kube. Commented Oct 17, 2019 at 7:43

1 Answer 1

1

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

Sign up to request clarification or add additional context in comments.

2 Comments

To be sure that you get the same file, in the same directory, try with this (absolute path to trydata.sql file because you copy the file with this path) ` mysqldump --u root --p"root" homestead > /trydata.sql;`
i have done everything as per suggestion, still not able to take backup.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.