From e1ef688e5a05f660434872e10114984a423b5ea2 Mon Sep 17 00:00:00 2001 From: jem Date: Wed, 29 Sep 2021 09:49:04 +0200 Subject: [PATCH] wip - only backup jira-export --- doc/BackupAndRestore.md | 26 ++-- doc/backup.svg | 123 +++++++----------- .../docker-backup/image/resources/backup.sh | 5 - .../resources/entrypoint-start-and-wait.sh | 6 - .../image/resources/entrypoint.sh | 8 +- .../docker-backup/image/resources/init.sh | 3 - .../image/resources/restic-snapshots.sh | 2 - .../docker-backup/image/resources/restore.sh | 12 -- src/main/resources/backup/backup-restore.yaml | 21 --- src/main/resources/backup/cron.yaml | 21 --- 10 files changed, 59 insertions(+), 168 deletions(-) diff --git a/doc/BackupAndRestore.md b/doc/BackupAndRestore.md index 3f6b129..0c9df64 100644 --- a/doc/BackupAndRestore.md +++ b/doc/BackupAndRestore.md @@ -4,8 +4,8 @@ * we use restic to produce small & encrypted backups * backup is scheduled at `schedule: "10 23 * * *"` -* Jira stores files on `/var/jira`, these files are backuped. If you create a jira xml backup located in /var/jira this file will also be backed up. -* postgres db is backed up as pgdump +* Jira stores files on `/var/jira/export`, these files are backuped. By default jira produces two exports per day. +* As jira provides a full xml export postgres is not needed. ## Manual init the restic repository for the first time @@ -19,29 +19,31 @@ ## Manual backup the restic repository for the first time -1. Scale Jira deployment down: - `kubectl scale deployment jira --replicas=0` +1.Create a jira export: + Jira > Settings > System -> Backup system +1. Choose a filename `backup-filename.xml`. Your file will be stored to `/var/backup/export`. 1. apply backup-and-restore pod: `kubectl apply -f src/main/resources/backup/backup-restore.yaml` 1. exec into pod and execute restore pod `kubectl exec -it backup-restore -- /usr/local/bin/backup.sh` 1. remove backup-and-restore pod: `kubectl delete pod backup-restore` -1. Scale Jira deployment up: - `kubectl scale deployment jira --replicas=1` ## Manual restore -1. Scale Jira deployment down: - `kubectl scale deployment jira --replicas=0` 1. apply backup-and-restore pod: `kubectl apply -f src/main/resources/backup/backup-restore.yaml` 1. exec into pod and execute restore pod `kubectl exec -it backup-restore -- /usr/local/bin/restore.sh` +1. In case of already set up server: + 1. Import one of Jira exportet backups: + Jira > Settings > System > Restore System + 1. Choose one of your bakcuped files located at `/var/jira/restic-restore/export/`. + E.g. `/var/jira/restic-restore/export/backup-filename.xml`. +1. In case of installation wizzard: + 1. Choose restore from backup + 1. Choose one of your bakcuped files located at `/var/jira/restic-restore/export/`. + E.g. `/var/jira/restic-restore/export/backup-filename.xml` 1. remove backup-and-restore pod: `kubectl delete pod backup-restore` -1. Scale Jira deployment up: - `kubectl scale deployment jira --replicas=1` -1. Update index of Jira: - Jira > Settings > System > Advanced > Indexing diff --git a/doc/backup.svg b/doc/backup.svg index 4f8bf15..6de802c 100644 --- a/doc/backup.svg +++ b/doc/backup.svg @@ -26,8 +26,8 @@ inkscape:pageopacity="0.0" inkscape:pageshadow="2" inkscape:zoom="1.4" - inkscape:cx="401.60934" - inkscape:cy="468.05499" + inkscape:cx="266.60934" + inkscape:cy="465.19785" inkscape:document-units="mm" inkscape:current-layer="layer1" showgrid="false" @@ -61,15 +61,10 @@ y="214.22322" id="text3897">/var/jira/var/postgres + id="tspan3899">/var/jira - - pod - postgrespod - - - - - - - - - with folder /jira + + + + + + postgres-pod diff --git a/infrastructure/docker-backup/image/resources/backup.sh b/infrastructure/docker-backup/image/resources/backup.sh index d01affd..ddd013c 100755 --- a/infrastructure/docker-backup/image/resources/backup.sh +++ b/infrastructure/docker-backup/image/resources/backup.sh @@ -5,18 +5,13 @@ set -o pipefail function main() { file_env AWS_ACCESS_KEY_ID file_env AWS_SECRET_ACCESS_KEY - file_env POSTGRES_DB - file_env POSTGRES_PASSWORD - file_env POSTGRES_USER file_env RESTIC_DAYS_TO_KEEP 14 backup-roles "" - backup-db-dump backup-fs-from-directory '/var/backups/' 'data/' } 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/entrypoint-start-and-wait.sh b/infrastructure/docker-backup/image/resources/entrypoint-start-and-wait.sh index 67a8f3b..0915071 100644 --- a/infrastructure/docker-backup/image/resources/entrypoint-start-and-wait.sh +++ b/infrastructure/docker-backup/image/resources/entrypoint-start-and-wait.sh @@ -1,11 +1,6 @@ #!/bin/bash function main() { - file_env POSTGRES_DB - file_env POSTGRES_PASSWORD - file_env POSTGRES_USER - - create-pg-pass while true; do sleep 1m @@ -13,5 +8,4 @@ function main() { } source /usr/local/lib/functions.sh -source /usr/local/lib/pg-functions.sh main \ No newline at end of file diff --git a/infrastructure/docker-backup/image/resources/entrypoint.sh b/infrastructure/docker-backup/image/resources/entrypoint.sh index 924f24c..b25e15f 100755 --- a/infrastructure/docker-backup/image/resources/entrypoint.sh +++ b/infrastructure/docker-backup/image/resources/entrypoint.sh @@ -1,15 +1,9 @@ #!/bin/bash function main() { - file_env POSTGRES_DB - file_env POSTGRES_PASSWORD - file_env POSTGRES_USER - - create-pg-pass - + /usr/local/bin/backup.sh } source /usr/local/lib/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 5693dcb..678f57c 100755 --- a/infrastructure/docker-backup/image/resources/init.sh +++ b/infrastructure/docker-backup/image/resources/init.sh @@ -4,12 +4,9 @@ function main() { file_env AWS_ACCESS_KEY_ID file_env AWS_SECRET_ACCESS_KEY - init-role-repo - init-database-repo init-file-repo } 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 a428fe2..ca889ce 100755 --- a/infrastructure/docker-backup/image/resources/restic-snapshots.sh +++ b/infrastructure/docker-backup/image/resources/restic-snapshots.sh @@ -6,8 +6,6 @@ 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 4798d5b..f8782a0 100755 --- a/infrastructure/docker-backup/image/resources/restore.sh +++ b/infrastructure/docker-backup/image/resources/restore.sh @@ -7,12 +7,6 @@ function main() { file_env AWS_ACCESS_KEY_ID file_env AWS_SECRET_ACCESS_KEY - file_env POSTGRES_DB - file_env POSTGRES_PASSWORD - file_env POSTGRES_USER - - # Im Jira pod: /opt/atlassian-jira-software-standalone/bin/stop-jira.sh - # Restore latest snapshot into /var/backups/restic-restore rm -rf /var/backups/restic-restore restore-directory '/var/backups/restic-restore' @@ -21,16 +15,10 @@ function main() { rm -rf /var/backups/data/* cp -a /var/backups/restic-restore/data/* /var/backups/data - # Restore db - drop-create-db - restore-roles - restore-db - # /opt/atlassian-jira-software-standalone/bin/start-jira.sh } 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 index c003650..8ae869a 100644 --- a/src/main/resources/backup/backup-restore.yaml +++ b/src/main/resources/backup/backup-restore.yaml @@ -12,27 +12,6 @@ spec: 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 diff --git a/src/main/resources/backup/cron.yaml b/src/main/resources/backup/cron.yaml index dd15add..e832bb7 100644 --- a/src/main/resources/backup/cron.yaml +++ b/src/main/resources/backup/cron.yaml @@ -18,27 +18,6 @@ spec: imagePullPolicy: IfNotPresent command: ["/entrypoint.sh"] env: - - name: POSTGRES_USER - valueFrom: - secretKeyRef: - name: postgres-secret - key: postgres-user - - name: POSTGRES_PASSWORD - valueFrom: - secretKeyRef: - name: postgres-secret - key: postgres-password - - name: POSTGRES_DB - valueFrom: - configMapKeyRef: - name: postgres-config - key: postgres-db - - 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