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..76026c58 100755 --- a/jobs/bbr-postgres-db/templates/restore.sh.erb +++ b/jobs/bbr-postgres-db/templates/restore.sh.erb @@ -23,6 +23,11 @@ export_as_private_temp_file "$JOB_DIR/config/pgpass" PGPASSFILE export_as_private_temp_file "$JOB_DIR/config/client_certificate_key" PGSSLKEY <% end %> +SINGLE_TRANSACTION= +<% if p("postgres.single-transaction") %> +SINGLE_TRANSACTION="--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,6 +46,7 @@ for dbname in ${DATABASES[@]}; do --use-list=${TMP_LIST_FILE} \ --if-exists \ --clean \ + ${SINGLE_TRANSACTION} \ "${BBR_ARTIFACT_FILE_PATH}" else echo "WARNING: Not restoring ${dbname} because backup file ${BBR_ARTIFACT_FILE_PATH} does not exist"