From aa0214569d4573fd182956a9f9ee4ce258f80286 Mon Sep 17 00:00:00 2001 From: Clemens Geibel Date: Fri, 16 Jul 2021 11:07:01 +0200 Subject: [PATCH] Added pg-functions to docker-backup and added backup-restore.yaml --- .../docker-backup/image/resources/backup.sh | 1 + .../docker-backup/image/resources/init.sh | 1 + .../image/resources/restic-snapshots.sh | 2 + .../docker-backup/image/resources/restore.sh | 1 + src/main/resources/backup/backup-restore.yaml | 62 +++++++++++++++++++ 5 files changed, 67 insertions(+) create mode 100644 src/main/resources/backup/backup-restore.yaml diff --git a/infrastructure/docker-backup/image/resources/backup.sh b/infrastructure/docker-backup/image/resources/backup.sh index 954090d..cf804ae 100755 --- a/infrastructure/docker-backup/image/resources/backup.sh +++ b/infrastructure/docker-backup/image/resources/backup.sh @@ -17,5 +17,6 @@ function main() { source /usr/local/lib/functions.sh source /usr/local/lib/file-functions.sh +source /usr/local/lib/pg-functions.sh main diff --git a/infrastructure/docker-backup/image/resources/init.sh b/infrastructure/docker-backup/image/resources/init.sh index 69ae9a0..9edd480 100755 --- a/infrastructure/docker-backup/image/resources/init.sh +++ b/infrastructure/docker-backup/image/resources/init.sh @@ -11,4 +11,5 @@ function main() { source /usr/local/lib/functions.sh source /usr/local/lib/file-functions.sh +source /usr/local/lib/pg-functions.sh main diff --git a/infrastructure/docker-backup/image/resources/restic-snapshots.sh b/infrastructure/docker-backup/image/resources/restic-snapshots.sh index ca889ce..cd1651a 100755 --- a/infrastructure/docker-backup/image/resources/restic-snapshots.sh +++ b/infrastructure/docker-backup/image/resources/restic-snapshots.sh @@ -6,6 +6,8 @@ function main() { file_env AWS_ACCESS_KEY_ID file_env AWS_SECRET_ACCESS_KEY + #restic -r ${RESTIC_REPOSITORY}/pg-role snapshots + restic -r ${RESTIC_REPOSITORY}/pg-database snapshots restic -r ${RESTIC_REPOSITORY}/files snapshots } diff --git a/infrastructure/docker-backup/image/resources/restore.sh b/infrastructure/docker-backup/image/resources/restore.sh index 26b0b17..f19f3ab 100755 --- a/infrastructure/docker-backup/image/resources/restore.sh +++ b/infrastructure/docker-backup/image/resources/restore.sh @@ -27,5 +27,6 @@ function main() { source /usr/local/lib/functions.sh source /usr/local/lib/file-functions.sh +source /usr/local/lib/pg-functions.sh main diff --git a/src/main/resources/backup/backup-restore.yaml b/src/main/resources/backup/backup-restore.yaml new file mode 100644 index 0000000..c003650 --- /dev/null +++ b/src/main/resources/backup/backup-restore.yaml @@ -0,0 +1,62 @@ +kind: Pod +apiVersion: v1 +metadata: + name: backup-restore + labels: + app.kubernetes.io/name: backup-restore + app.kubernetes.io/part-of: jira +spec: + containers: + - name: backup-app + image: domaindrivenarchitecture/c4k-jira-backup + imagePullPolicy: IfNotPresent + command: ["/entrypoint-start-and-wait.sh"] + env: + - name: POSTGRES_USER + valueFrom: + secretKeyRef: + name: postgres-secret + key: postgres-user + - name: POSTGRES_DB + valueFrom: + configMapKeyRef: + name: postgres-config + key: postgres-db + - name: POSTGRES_PASSWORD + valueFrom: + secretKeyRef: + name: postgres-secret + key: postgres-password + - name: POSTGRES_HOST + value: "postgresql-service:5432" + - name: POSTGRES_SERVICE + value: "postgresql-service" + - name: POSTGRES_PORT + value: "5432" + - name: AWS_DEFAULT_REGION + value: eu-central-1 + - name: AWS_ACCESS_KEY_ID_FILE + value: /var/run/secrets/backup-secrets/aws-access-key-id + - name: AWS_SECRET_ACCESS_KEY_FILE + value: /var/run/secrets/backup-secrets/aws-secret-access-key + - name: RESTIC_REPOSITORY + valueFrom: + configMapKeyRef: + name: backup-config + key: restic-repository + - name: RESTIC_PASSWORD_FILE + value: /var/run/secrets/backup-secrets/restic-password + volumeMounts: + - name: jira-data-volume + mountPath: /var/backups + - name: backup-secret-volume + mountPath: /var/run/secrets/backup-secrets + readOnly: true + volumes: + - name: jira-data-volume + persistentVolumeClaim: + claimName: jira-pvc + - name: backup-secret-volume + secret: + secretName: backup-secret + restartPolicy: OnFailure \ No newline at end of file