- Create a cronjob to back up node1 data to node8 - Define schedule for daily backups at 3:00 AM - Include error handling and notifications via Feishu - Use SSH and rsync for secure and efficient data transfer This commit introduces a new cronjob that automates the backup process for node1 to node8, enabling easier management and recovery of data. The setup includes necessary security measures and proper logging of backups, ensuring smoother operation and notifications in case of failures.
34 lines
936 B
YAML
34 lines
936 B
YAML
apiVersion: v1
|
|
kind: Namespace
|
|
metadata:
|
|
name: backup-system
|
|
---
|
|
apiVersion: batch/v1
|
|
kind: CronJob
|
|
metadata:
|
|
name: node-backup-job
|
|
namespace: backup-system
|
|
spec:
|
|
# 每天凌晨2点运行
|
|
schedule: "0 2 * * *"
|
|
concurrencyPolicy: Forbid
|
|
jobTemplate:
|
|
spec:
|
|
ttlSecondsAfterFinished: 86400 # 1天后删除已完成的任务
|
|
template:
|
|
spec:
|
|
serviceAccountName: backup-service-account
|
|
nodeSelector:
|
|
kubernetes.io/hostname: "vkvm-us1"
|
|
containers:
|
|
- name: backup-trigger
|
|
image: bitnami/kubectl:latest
|
|
command:
|
|
- /bin/sh
|
|
- -c
|
|
- |
|
|
kubectl label daemonset/node-backup-daemon trigger-backup=true --overwrite -n backup-system && \
|
|
sleep 60 && \
|
|
kubectl label daemonset/node-backup-daemon trigger-backup- -n backup-system
|
|
restartPolicy: OnFailure
|