57 lines
1.4 KiB
YAML
57 lines
1.4 KiB
YAML
apiVersion: batch/v1
|
|
kind: CronJob
|
|
metadata:
|
|
name: backup
|
|
spec:
|
|
schedule: "0 1 * * *"
|
|
jobTemplate:
|
|
spec:
|
|
template:
|
|
spec:
|
|
volumes:
|
|
- name: tmp
|
|
emptyDir:
|
|
medium: Memory
|
|
- name: target
|
|
hostPath:
|
|
path: /data/hermes
|
|
- name: backup-script
|
|
configMap:
|
|
name: backup-script
|
|
# 初始化阶段打包
|
|
initContainers:
|
|
- name: backup-package
|
|
# image: busybox:1.28
|
|
image: package
|
|
command:
|
|
- /bin/sh
|
|
- /backup.sh
|
|
volumeMounts:
|
|
- mountPath: /tmp
|
|
name: tmp
|
|
- mountPath: /target/hermes
|
|
name: target
|
|
readOnly: true
|
|
- mountPath: /backup.sh
|
|
name: backup-script
|
|
subPath: backup.sh
|
|
containers:
|
|
- name: backup-upload
|
|
# image amazon/aws-cli:2.34.57
|
|
image: aws
|
|
envFrom:
|
|
- secretRef:
|
|
name: backup-env
|
|
- configMapRef:
|
|
name: backup-env
|
|
args:
|
|
- s3
|
|
- sync
|
|
- "./hermes-backup"
|
|
- "s3://senset-backups/hermes-data"
|
|
volumeMounts:
|
|
- mountPath: /aws
|
|
name: tmp
|
|
readOnly: true
|
|
restartPolicy: OnFailure
|