Skip to content

Commit

Permalink
fix: split resources
Browse files Browse the repository at this point in the history
  • Loading branch information
georgepstaylor committed Nov 21, 2024
1 parent 1ded362 commit 8b7f8e5
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 25 deletions.
25 changes: 25 additions & 0 deletions helm/migrate-db/templates/config-map.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
---
apiVersion: v1
kind: ConfigMap
metadata:
name: migrate-db-script
data:
entrypoint.sh: |-
#!/bin/bash
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
chmod 0600 ~/.pgpass
chown job:job ~/.pgpass
set -x
# 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
25 changes: 0 additions & 25 deletions helm/migrate-db/templates/job.yaml
Original file line number Diff line number Diff line change
@@ -1,29 +1,4 @@
---
apiVersion: v1
kind: ConfigMap
metadata:
name: migrate-db-script
data:
entrypoint.sh: |-
#!/bin/bash
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
chmod 0600 ~/.pgpass
chown job:job ~/.pgpass
set -x
# 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
metadata:
Expand Down

0 comments on commit 8b7f8e5

Please sign in to comment.