diff --git a/jobs/migrate-db/templates/job.yaml b/jobs/migrate-db/templates/job.yaml index 6baddb9..b09247e 100644 --- a/jobs/migrate-db/templates/job.yaml +++ b/jobs/migrate-db/templates/job.yaml @@ -9,12 +9,21 @@ data: set -e echo "${SRC_DB_HOST}:5432:${SRC_DB_NAME}:${SRC_DB_USER}:${SRC_DB_PASS}" > ~/.pgpass echo "${DST_DB_HOST}:5432:${DST_DB_NAME}:${DST_DB_USER}:${DST_DB_PASS}" >> ~/.pgpass + cat ~/.pgpass chmod 0600 ~/.pgpass + chown job:job ~/.pgpass set -x - pg_dump --jobs=4 --host="$SRC_DB_HOST" --username="$SRC_DB_USER" --dbname="$SRC_DB_NAME" --no-owner --no-privileges --verbose --format=directory --file=/tmp/db-dump - pg_restore --jobs=4 --host="$DST_DB_HOST" --username="$DST_DB_USER" --dbname="$DST_DB_NAME" --clean --if-exists --no-owner --no-privileges --verbose /tmp/db-dump - rm -rv /tmp/db-dump ~/.pgpass + # Dump the source database + pg_dump --jobs=4 --host="$SRC_DB_HOST" --username="$SRC_DB_USER" --dbname="$SRC_DB_NAME" --no-owner --no-privileges --verbose --format=directory --file=/home/job/db-dump + + psql --host="$DST_DB_HOST" --username="$DST_DB_USER" --dbname="$DST_DB_NAME" -c "drop schema if exists public cascade;" + + psql --host="$DST_DB_HOST" --username="$DST_DB_USER" --dbname="$DST_DB_NAME" -c "create schema public;" + + # Restore the source database dump to the destination database + pg_restore --jobs=4 --host="$DST_DB_HOST" --username="$DST_DB_USER" --dbname="$DST_DB_NAME" --no-owner --no-privileges --verbose /home/job/db-dump + rm -rv /home/job/db-dump ~/.pgpass --- apiVersion: batch/v1 kind: Job @@ -25,7 +34,7 @@ spec: spec: containers: - name: migrate-db - image: postgres:14 + image: ghcr.io/ministryofjustice/hmpps-delius-alfresco-db-utils:latest imagePullPolicy: IfNotPresent resources: limits: diff --git a/jobs/migrate-s3/templates/job.yaml b/jobs/migrate-s3/templates/job.yaml index 669e5b8..ea093db 100644 --- a/jobs/migrate-s3/templates/job.yaml +++ b/jobs/migrate-s3/templates/job.yaml @@ -9,9 +9,9 @@ data: set -xe aws configure set default.s3.max_concurrent_requests 2000 - aws configure set default.s3.use_accelerate_endpoint true + # aws configure set default.s3.use_accelerate_endpoint true - aws s3 sync s3://$SRC_BUCKET/$DIR s3://$DST_BUCKET/$DIR --delete --only-show-errors + aws s3 sync s3://$SRC_BUCKET/$DIR s3://$DST_BUCKET/$DIR --delete --only-show-errors --region eu-west-2 echo sync of $DIR directory completed {{- range .Values.dirs }} @@ -29,8 +29,8 @@ spec: imagePullPolicy: IfNotPresent resources: limits: - cpu: 4 - memory: 8Gi + cpu: 1 + memory: 1Gi command: - /bin/entrypoint.sh env: diff --git a/jobs/refresh-db/templates/job.yaml b/jobs/refresh-db/templates/job.yaml index 97a45b9..1d3a837 100644 --- a/jobs/refresh-db/templates/job.yaml +++ b/jobs/refresh-db/templates/job.yaml @@ -48,7 +48,7 @@ spec: spec: containers: - name: refresh-db - image: ghcr.io/ministryofjustice/hmpps-delius-alfresco-db-utils:NIT-1403-alfresco-move-away-from-long-running-github-workflows-10114657186 + image: ghcr.io/ministryofjustice/hmpps-delius-alfresco-db-utils:latest imagePullPolicy: IfNotPresent resources: limits: diff --git a/test.yml b/test.yml deleted file mode 100644 index e69de29..0000000