From b23cc7c88e5f71d1383eea43a1d2f7b424c4e540 Mon Sep 17 00:00:00 2001 From: ramonskie Date: Thu, 30 Jan 2020 16:56:30 +0100 Subject: [PATCH 1/5] add singel-transaction option --- jobs/bbr-postgres-db/spec | 3 +++ jobs/bbr-postgres-db/templates/restore.sh.erb | 3 +++ 2 files changed, 6 insertions(+) diff --git a/jobs/bbr-postgres-db/spec b/jobs/bbr-postgres-db/spec index 9d8771b5..3db8b7fb 100644 --- a/jobs/bbr-postgres-db/spec +++ b/jobs/bbr-postgres-db/spec @@ -44,3 +44,6 @@ properties: postgres.client_certificate_key: default: '' description: "Secret key used for the client certificate. Specify it if you want to auhtenticate using certificates." + postgres.single-transaction: + default: false + description: "uses singele transaction when restoring databases" diff --git a/jobs/bbr-postgres-db/templates/restore.sh.erb b/jobs/bbr-postgres-db/templates/restore.sh.erb index ca1b60d2..50ec5d1b 100755 --- a/jobs/bbr-postgres-db/templates/restore.sh.erb +++ b/jobs/bbr-postgres-db/templates/restore.sh.erb @@ -41,6 +41,9 @@ for dbname in ${DATABASES[@]}; do --use-list=${TMP_LIST_FILE} \ --if-exists \ --clean \ + <% if p("postgres.single-transaction") %> + --single-transaction \ + <% end %> "${BBR_ARTIFACT_FILE_PATH}" else echo "WARNING: Not restoring ${dbname} because backup file ${BBR_ARTIFACT_FILE_PATH} does not exist" From 18d76b452f10d1768bce0e712c7cd936de7cb1bb Mon Sep 17 00:00:00 2001 From: ramonskie Date: Mon, 3 Feb 2020 10:15:09 +0100 Subject: [PATCH 2/5] when false or true always add " --- jobs/bbr-postgres-db/templates/restore.sh.erb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/jobs/bbr-postgres-db/templates/restore.sh.erb b/jobs/bbr-postgres-db/templates/restore.sh.erb index 50ec5d1b..7bb58e1f 100755 --- a/jobs/bbr-postgres-db/templates/restore.sh.erb +++ b/jobs/bbr-postgres-db/templates/restore.sh.erb @@ -42,8 +42,8 @@ for dbname in ${DATABASES[@]}; do --if-exists \ --clean \ <% if p("postgres.single-transaction") %> - --single-transaction \ - <% end %> + --single-transaction + <% end %> \ "${BBR_ARTIFACT_FILE_PATH}" else echo "WARNING: Not restoring ${dbname} because backup file ${BBR_ARTIFACT_FILE_PATH} does not exist" From 49405a304567e6ba40717a1cde8116b0fff47007 Mon Sep 17 00:00:00 2001 From: ramonskie Date: Mon, 3 Feb 2020 13:38:50 +0100 Subject: [PATCH 3/5] set transaction in variable --- jobs/bbr-postgres-db/templates/restore.sh.erb | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/jobs/bbr-postgres-db/templates/restore.sh.erb b/jobs/bbr-postgres-db/templates/restore.sh.erb index 7bb58e1f..e49c77f7 100755 --- a/jobs/bbr-postgres-db/templates/restore.sh.erb +++ b/jobs/bbr-postgres-db/templates/restore.sh.erb @@ -23,6 +23,10 @@ export_as_private_temp_file "$JOB_DIR/config/pgpass" PGPASSFILE export_as_private_temp_file "$JOB_DIR/config/client_certificate_key" PGSSLKEY <% end %> +<% if p("postgres.single-transaction") %> +singeltrans="--single-transaction" +<% end %> + for dbname in ${DATABASES[@]}; do BBR_ARTIFACT_FILE_PATH="${BBR_ARTIFACT_DIRECTORY}/postgres_${dbname}.sql" if [ -f "${BBR_ARTIFACT_FILE_PATH}" ]; then @@ -41,9 +45,7 @@ for dbname in ${DATABASES[@]}; do --use-list=${TMP_LIST_FILE} \ --if-exists \ --clean \ - <% if p("postgres.single-transaction") %> - --single-transaction - <% end %> \ + ${singeltrans} \ "${BBR_ARTIFACT_FILE_PATH}" else echo "WARNING: Not restoring ${dbname} because backup file ${BBR_ARTIFACT_FILE_PATH} does not exist" From 0f5bf1019c54167fbee3e395c5299503f145a663 Mon Sep 17 00:00:00 2001 From: ramonskie Date: Tue, 4 Feb 2020 13:08:17 +0100 Subject: [PATCH 4/5] init var and proper var names --- jobs/bbr-postgres-db/templates/restore.sh.erb | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/jobs/bbr-postgres-db/templates/restore.sh.erb b/jobs/bbr-postgres-db/templates/restore.sh.erb index e49c77f7..783938ad 100755 --- a/jobs/bbr-postgres-db/templates/restore.sh.erb +++ b/jobs/bbr-postgres-db/templates/restore.sh.erb @@ -23,8 +23,9 @@ export_as_private_temp_file "$JOB_DIR/config/pgpass" PGPASSFILE export_as_private_temp_file "$JOB_DIR/config/client_certificate_key" PGSSLKEY <% end %> +SINGLETRANSACTION= <% if p("postgres.single-transaction") %> -singeltrans="--single-transaction" +SINGLETRANSACTION="--single-transaction" <% end %> for dbname in ${DATABASES[@]}; do @@ -45,7 +46,7 @@ for dbname in ${DATABASES[@]}; do --use-list=${TMP_LIST_FILE} \ --if-exists \ --clean \ - ${singeltrans} \ + ${SINGLETRANSACTION} \ "${BBR_ARTIFACT_FILE_PATH}" else echo "WARNING: Not restoring ${dbname} because backup file ${BBR_ARTIFACT_FILE_PATH} does not exist" From 6ed4c4650c1c83d403af2eb3d57666bd1c90bd32 Mon Sep 17 00:00:00 2001 From: ramonskie Date: Tue, 4 Feb 2020 13:24:49 +0100 Subject: [PATCH 5/5] proper var name --- jobs/bbr-postgres-db/templates/restore.sh.erb | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/jobs/bbr-postgres-db/templates/restore.sh.erb b/jobs/bbr-postgres-db/templates/restore.sh.erb index 783938ad..76026c58 100755 --- a/jobs/bbr-postgres-db/templates/restore.sh.erb +++ b/jobs/bbr-postgres-db/templates/restore.sh.erb @@ -23,9 +23,9 @@ export_as_private_temp_file "$JOB_DIR/config/pgpass" PGPASSFILE export_as_private_temp_file "$JOB_DIR/config/client_certificate_key" PGSSLKEY <% end %> -SINGLETRANSACTION= +SINGLE_TRANSACTION= <% if p("postgres.single-transaction") %> -SINGLETRANSACTION="--single-transaction" +SINGLE_TRANSACTION="--single-transaction" <% end %> for dbname in ${DATABASES[@]}; do @@ -46,7 +46,7 @@ for dbname in ${DATABASES[@]}; do --use-list=${TMP_LIST_FILE} \ --if-exists \ --clean \ - ${SINGLETRANSACTION} \ + ${SINGLE_TRANSACTION} \ "${BBR_ARTIFACT_FILE_PATH}" else echo "WARNING: Not restoring ${dbname} because backup file ${BBR_ARTIFACT_FILE_PATH} does not exist"