From 8be078b09cd5ae920ba374bfe58e87ad7b9b4ece Mon Sep 17 00:00:00 2001 From: jem Date: Fri, 12 Nov 2021 09:12:03 +0100 Subject: [PATCH] backup&restore doc --- doc/BackupAndRestore.md | 47 +++++++ doc/SetupOnHetzner.md | 74 ++++++++++ doc/backup.svg | 294 ++++++++++++++++++++++++++++++++++++++++ 3 files changed, 415 insertions(+) create mode 100644 doc/BackupAndRestore.md create mode 100644 doc/SetupOnHetzner.md create mode 100644 doc/backup.svg diff --git a/doc/BackupAndRestore.md b/doc/BackupAndRestore.md new file mode 100644 index 0000000..3f6b129 --- /dev/null +++ b/doc/BackupAndRestore.md @@ -0,0 +1,47 @@ +# Backup Architecture details + +![](backup.svg) + +* 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 + +## Manual init the restic repository for the first time + +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/init.sh` +1. remove backup-and-restore pod: + `kubectl delete pod backup-restore + + +## Manual backup the restic repository for the first time + +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/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. 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/SetupOnHetzner.md b/doc/SetupOnHetzner.md new file mode 100644 index 0000000..3117fa1 --- /dev/null +++ b/doc/SetupOnHetzner.md @@ -0,0 +1,74 @@ +# Setup +## Infrastructure on Hetzner / Aws + +For a setup on hetzner / aws we use terraform. + +``` +resource "aws_s3_bucket" "backup" { + bucket = "backup" + acl = "private" + + versioning { + enabled = false + } + tags = { + name = "backup" + Description = "bucket for backups in stage: ${var.stage}" + } +} + +resource "hcloud_server" "jira_09_2021" { + name = "the name" + image = "ubuntu-20.04" + server_type = "cx31" + location = "fsn1" + ssh_keys = ... + + lifecycle { + ignore_changes = [ssh_keys] + } +} + +resource "aws_route53_record" "v4_neu" { + zone_id = the_dns_zone + name = "jira-neu" + type = "A" + ttl = "300" + records = [hcloud_server.jira_09_2021.ipv4_address] +} + +output "ipv4" { + value = hcloud_server.jira_09_2021.ipv4_address +} + +``` + +## k8s minicluster + +For k8s installation we use our [dda-k8s-crate](https://github.com/DomainDrivenArchitecture/dda-k8s-crate) with the following configuation: + + +``` +{:user :k8s + :k8s {:external-ip "ip-from-above"} + :cert-manager :letsencrypt-prod-issuer + :persistent-dirs ["jira", "postgres"] + } +``` + +## kubectl apply c4k-jira + +The last step for applying the jira deployment is + +``` +c4k-jira config.edn auth.edn | kubectl apply -f - +``` + +with the following config.edn: + +``` +{:fqdn "the-fqdn-from aws_route53_record.v4_neu" + :jira-data-volume-path "/var/jira" ;; Volume was configured at dda-k8s-crate, results in a PersistentVolume definition. + :postgres-data-volume-path "/var/postgres" ;; Volume was configured at dda-k8s-crate, results in a PersistentVolume definition. + :restic-repository "s3:s3.amazonaws.com/your-bucket/your-folder"} +``` diff --git a/doc/backup.svg b/doc/backup.svg new file mode 100644 index 0000000..4f8bf15 --- /dev/null +++ b/doc/backup.svg @@ -0,0 +1,294 @@ + + + + + + + + + + image/svg+xml + + + + + + + /var/jira/var/postgres + + + + + + + + + + + + + + + + + + + jira-pod + backuppod + postgrespod + + + + + + + + + + + + restic - backup + S3-Bucketwith folder /jira + +