我们在带有MySQL数据库的k8s(GCP)中部署了一个laravel项目。现在,我想在cronjob的帮助下定时备份该数据库,我遵循了articles,但无法创建备份文件。但是,根据文章,我们需要在GCP
中创建存储桶和服务帐户它仍然可以正常工作,但存储桶中没有备份文件。
cronjob.yaml文件
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
restartPolicy: OnFailure
答案 0 :(得分:0)
您没有复制正确的文件:
mysqldump --u root --p“ root” homestead> trydata.sql ; gcloud config设置项目gcloud auth activate-service-account-密钥文件备份; gsutil cp /laravel.sql gs:// backup-buck