From e24f56b6f32155e19a6d22665180abc56c0be218 Mon Sep 17 00:00:00 2001 From: Pierre Ozoux <pierre@ozoux.net> Date: Thu, 2 Dec 2021 11:21:51 +0100 Subject: [PATCH] Adds 2 missing scripts from server. --- migrations/30-09-2021-group-mapping-Nc.sh | 14 ++++++++ nextcloud/other-manifests/restore.yml | 44 +++++++++++++++++++++++ 2 files changed, 58 insertions(+) create mode 100644 migrations/30-09-2021-group-mapping-Nc.sh create mode 100644 nextcloud/other-manifests/restore.yml diff --git a/migrations/30-09-2021-group-mapping-Nc.sh b/migrations/30-09-2021-group-mapping-Nc.sh new file mode 100644 index 0000000..33f2fbd --- /dev/null +++ b/migrations/30-09-2021-group-mapping-Nc.sh @@ -0,0 +1,14 @@ +#!/bin/bash + +# List instances where indie_external is not enabled +# If an app is enabled it prints the version, if not, it doesn't + +for ns in `kubectl get ns --no-headers -o custom-columns=":metadata.name"`; do # Loop all Ns + po=`kubectl -n $ns get po -l app.kubernetes.io/name=nextcloud,app.kubernetes.io/component=app --no-headers -o custom-columns=":metadata.name" | head -n1` # Get the first po + if [ ! -z "$po" ]; then # if there is Nc in this Ns + if ! kubectl -n $ns exec $po -- php /usr/src/nextcloud/occ config:app:get user_saml saml-attribute-mapping-group_mapping | grep -q "groups"; then # check that our app is not activated + echo $ns # Print ns if Nc installed and app not activated + fi + fi +done + diff --git a/nextcloud/other-manifests/restore.yml b/nextcloud/other-manifests/restore.yml new file mode 100644 index 0000000..71bf97d --- /dev/null +++ b/nextcloud/other-manifests/restore.yml @@ -0,0 +1,44 @@ +apiVersion: batch/v1 +kind: Job +metadata: + labels: + application: spilo-logical-backup + job-name: restore + name: restore +spec: + backoffLimit: 6 + completions: 1 + parallelism: 1 + selector: + matchLabels: + job-name: restore + template: + metadata: + creationTimestamp: null + labels: + application: spilo-logical-backup + job-name: restore + spec: + containers: + - command: + - /bin/sh + - -c + args: + - sleep 100000000 + - aws s3 cp s3://${NS}-dumps/migrations/$(date +%m-%d-%Y).sql.gz - --endpoint-url=https://minio.k7.indie.host --region=default | unpigz | pg_restore -d nextcloud -h pg-${PG_DOMAIN} -p 5432 -U nextcloud --clean --no-owner --role=nextcloud -n public + env: + - name: PGPASSWORD + valueFrom: + secretKeyRef: + key: password + name: nextcloud.pg-${NS}.credentials + - name: AWS_S3_FORCE_PATH_STYLE + value: "true" + envFrom: + - secretRef: + name: ${NS}-dumps + image: registry.opensource.zalan.do/acid/logical-backup:v1.6.2 + imagePullPolicy: IfNotPresent + name: logical-backup + restartPolicy: Never + -- GitLab