Skip to content

Instantly share code, notes, and snippets.

@krogebry
Created June 9, 2021 22:11
Show Gist options
  • Save krogebry/054fc2ee3bedc553eea2edb753ba8e88 to your computer and use it in GitHub Desktop.
Save krogebry/054fc2ee3bedc553eea2edb753ba8e88 to your computer and use it in GitHub Desktop.
apiVersion: batch/v1beta1
kind: CronJob
metadata:
name: influxdb-backup
spec:
concurrencyPolicy: Allow
failedJobsHistoryLimit: 10
jobTemplate:
spec:
template:
spec:
containers:
- args:
- -c
- |
#!/bin/sh
aws s3 sync /backup/ s3://${SRC_URL}/$(date +%Y%m%d)
command:
- /bin/sh
env:
- name: SRC_URL
value: bucket_name/trp/{{ .Release.Namespace }}/backups/influxdb
- name: AWS_ACCESS_KEY_ID
valueFrom:
secretKeyRef:
key: access-key
name: aws-access-creds
- name: AWS_DEFAULT_REGION
value: us-east-1
- name: AWS_SECRET_ACCESS_KEY
valueFrom:
secretKeyRef:
key: secret-key
name: aws-access-creds
image: amazon/aws-cli
imagePullPolicy: Always
name: ship-backup
resources:
limits:
cpu: 500m
memory: 512Mi
requests:
cpu: 100m
memory: 128Mi
terminationMessagePath: /dev/termination-log
terminationMessagePolicy: File
volumeMounts:
- mountPath: /backup
name: backup
dnsPolicy: ClusterFirst
initContainers:
- args:
- -c
- |
#!/bin/sh
cd /backup
rm -rf * ## remove old backup data
influxd backup --host influxdb:8088 --portable .
command:
- /bin/sh
image: influxdb:1.8
imagePullPolicy: IfNotPresent
name: backup-influx
resources:
limits:
cpu: "2"
memory: 8Gi
requests:
cpu: "1"
memory: 4Gi
volumeMounts:
- mountPath: /backup
name: backup
restartPolicy: OnFailure
schedulerName: default-scheduler
securityContext: {}
terminationGracePeriodSeconds: 30
volumes:
- name: backup
persistentVolumeClaim:
claimName: influxdb-backups
schedule: 0 1 * * *
successfulJobsHistoryLimit: 3
suspend: false
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment