aboutsummaryrefslogtreecommitdiff
path: root/rpi5/teslamate/backup.yaml
blob: 8d21679451a3029ded43c1cefc5dcc96d4050137 (plain) (blame)
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
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
apiVersion: batch/v1
kind: CronJob
metadata:
  name: teslamate-backup
spec:
  schedule: "14 8 * * *"
  concurrencyPolicy: Forbid
  jobTemplate:
    spec:
      template:
        spec:
          initContainers:
            - name: pgdump
              image: postgres:17.6@sha256:ab24d83d6a893f98acde5cd4264ab3c94329313c92ba92c71c2e7ce49ca8b1c6
              imagePullPolicy: IfNotPresent
              command:
                - sh
                - -euxc
                - |
                  pg_dump -p 5432 teslamate > /backup/backup.sql
              env:
                - name: PGHOST
                  valueFrom:
                    secretKeyRef:
                      key: host
                      name: database-secrets
                - name: PGUSER
                  valueFrom:
                    secretKeyRef:
                      key: username
                      name: database-secrets
                - name: PGPASSWORD
                  valueFrom:
                    secretKeyRef:
                      name: database-secrets
                      key: password
              volumeMounts:
                - mountPath: /backup
                  name: backup
          containers:
            - name: restic
              image: creativeprojects/resticprofile:0.31.0@sha256:7aa9467ba73f44e1306b6143fa91af65d3652a964c1b44a83920d2e1336a0944
              imagePullPolicy: IfNotPresent
              command: [ "resticprofile", "backup" ]
              env:
                - name: RESTIC_REST_USERNAME
                  value: "teslamate"
                - name: RESTIC_REST_PASSWORD
                  valueFrom:
                    secretKeyRef:
                      key: restPassword
                      name: secrets
              volumeMounts:
                - mountPath: /resticprofile/profiles.yaml
                  name: profile
                  subPath: profiles.yaml
                - mountPath: /resticprofile/password
                  name: secrets
                  subPath: password
                - mountPath: /backup
                  name: backup
          restartPolicy: OnFailure
          volumes:
            - name: backup
              emptyDir: { }
            - name: profile
              configMap:
                name: resticprofile
            - name: secrets
              secret:
                secretName: secrets
---
apiVersion: v1
kind: ConfigMap
metadata:
  name: resticprofile
data:
  profiles.yaml: |
    version: "1"

    default:
      repository: "rest:https://restic.anshulg.com/teslamate/"
      initialize: true
      password-file: "/resticprofile/password"
      compression: "max"
      force-inactive-lock: true

      env:
        RESTIC_HOST: "teslamate"

      retention:
        before-backup: false
        after-backup: true
        keep-daily: 7
        keep-weekly: 4
        keep-monthly: 1
        prune: true
        host: false

      backup:
        source:
          - "/backup"
        tag:
          - "teslamate"