Backup Storage in KubernetesΒΆ
It is possible to utilize the ASERGO remote backup storage in your Kubernetes clusters.
You can check if your cluster has backup storage activated with the following command.
kubectl get pv asergo-backup 2> /dev/null && echo "OK" || echo "PV NOT FOUND - Contact Support"
This service is not an automated backup solution of the cluster or application data. The service supplies an easy way to access the ASERGO Backup Storage directly in your cluster. You will have to create the backup job yourself.
Below is an example of a Kubernetes cronJob taking a backup of a Postgres database every 24 hours.
apiVersion: batch/v1
kind: CronJob
metadata:
name: backup-job
spec:
schedule: "0 0 * * *"
jobTemplate:
spec:
template:
spec:
containers:
- name: backup-job
image: postgres
imagePullPolicy: IfNotPresent
command: ["/bin/sh", "-c", "/scripts/backup.sh"]
volumeMounts:
- name: backup-script
mountPath: /scripts
- name: backup-data
mountPath: /data
restartPolicy: OnFailure
volumes:
- name: backup-script
configMap:
name: backup-job
- name: backup-data
persistentVolumeClaim:
claimName: backup-pvc
apiVersion: v1
kind: PersistentVolumeClaim
metadata:
name: backup-pvc
spec:
accessModes:
- ReadWriteMany
volumeName: asergo-backup
storageClassName: nfs-manual
volumeMode: Filesystem
volumeName: asergo-backup
apiVersion: v1
kind: ConfigMap
metadata:
name: backup-job
data:
backup.sh |
pg_dump "host=postgres port=5432 dbname=db user=root password=password" > /data/postgres/$(date +"%s")-db.sql