~sbaildon/cluster

ref: a8baba7c cluster/projects/crave_supply/database/backups/backup.yaml -rw-r--r-- 2.2 KiB
a8baba7cSean Baildon container registry 0 replicas a month ago
                                                                                
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
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
apiVersion: batch/v1beta1
kind: CronJob
metadata:
  name: postgres-backup
spec:
  schedule: "30 04 */1 * *"
  suspend: true
  jobTemplate:
    spec:
      template:
        spec:
          volumes:
            - name: data
              emptyDir: {}
          initContainers:
            - name: dump
              image: docker.io/postgres:13.2-alpine
              imagePullPolicy: IfNotPresent
              volumeMounts:
                - name: data
                  mountPath: /var/lib/postgres/backups
              command:
                - "/bin/sh"
              args:
                - "-c"
                - "pg_dump $(printenv DATABASE_URL) > /var/lib/postgres/backups/$(date -Iseconds --utc).sql"
              env:
                - name: DATABASE_URL
                  valueFrom:
                    secretKeyRef:
                      name: crave-config
                      key: crave_supply_database_url
          containers:
            - name: backup
              image: docker.io/restic/restic:0.12.0
              imagePullPolicy: IfNotPresent
              volumeMounts:
                - name: data
                  mountPath: /var/lib/postgres/backups
              command:
                - restic
              args:
                - backup
                - --tag
                - cronjob
                - /var/lib/postgres/backups
              env:
                - name: AWS_ACCESS_KEY_ID
                  valueFrom:
                    secretKeyRef:
                      name: postgres-backup-storage-credentials
                      key: access_key
                - name: AWS_SECRET_ACCESS_KEY
                  valueFrom:
                    secretKeyRef:
                      name: postgres-backup-storage-credentials
                      key: secret_key
                - name: RESTIC_REPOSITORY
                  valueFrom:
                    secretKeyRef:
                      name: postgres-backup-repository
                      key: repository
                - name: RESTIC_PASSWORD
                  valueFrom:
                    secretKeyRef:
                      name: postgres-backup-repository
                      key: password
          restartPolicy: OnFailure