This repository has been archived by the owner on Sep 26, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathzeebe-backup-job.yaml
53 lines (51 loc) · 1.78 KB
/
zeebe-backup-job.yaml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
apiVersion: batch/v1
kind: Job
metadata:
name: zeebe-backup-job
spec:
template:
spec:
containers:
- name: zeebe-backup-script
image: curlimages/curl
env:
- name: BACKUP_TIME_ID
valueFrom:
secretKeyRef:
name: backup-timeid
key: backupTimeId
command: ["/bin/sh"]
args:
- -c
- |
# Trigger the backup
curl -X POST "http://camunda-zeebe-gateway:9600/actuator/backups" \
-H 'Content-Type: application/json' \
-d "{\"backupId\": \"$BACKUP_TIME_ID\"}"
echo "Backup trigger request sent for ID $BACKUP_TIME_ID"
sleep 5
# Monitor backup status
fail_count=0
while true; do
response=$(curl -s "http://camunda-zeebe-gateway:9600/actuator/backups/$BACKUP_TIME_ID")
echo "$response"
# Check if the response includes the specific backupId and state COMPLETED
if echo "$response" | grep -q "\"backupId\":$BACKUP_TIME_ID,\"state\":\"COMPLETED\""; then
echo "Backup $BACKUP_TIME_ID completed successfully."
break
elif echo "$response" | grep -q "\"state\":\"IN_PROGRESS\""; then
echo "Backup $BACKUP_TIME_ID in progress, checking again in 30s."
sleep 30
else
echo "Backup $BACKUP_TIME_ID failed or in an unknown state."
fail_count=$((fail_count+1))
if [ $fail_count -ge 3 ]; then
echo "Failed 3 times, exiting."
exit 1
else
echo "Retrying, attempt $fail_count of 3."
sleep 30
fi
fi
done
restartPolicy: Never