Skip to content

Commit 44351f3

Browse files
authored
add single-transaction option in restore command (#55)
1 parent e19399d commit 44351f3

File tree

2 files changed

+9
-0
lines changed

2 files changed

+9
-0
lines changed

jobs/bbr-postgres-db/spec

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,3 +44,6 @@ properties:
4444
postgres.client_certificate_key:
4545
default: ''
4646
description: "Secret key used for the client certificate. Specify it if you want to auhtenticate using certificates."
47+
postgres.single-transaction:
48+
default: false
49+
description: "uses singele transaction when restoring databases"

jobs/bbr-postgres-db/templates/restore.sh.erb

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,11 @@ export_as_private_temp_file "$JOB_DIR/config/pgpass" PGPASSFILE
2323
export_as_private_temp_file "$JOB_DIR/config/client_certificate_key" PGSSLKEY
2424
<% end %>
2525

26+
SINGLE_TRANSACTION=
27+
<% if p("postgres.single-transaction") %>
28+
SINGLE_TRANSACTION="--single-transaction"
29+
<% end %>
30+
2631
for dbname in ${DATABASES[@]}; do
2732
BBR_ARTIFACT_FILE_PATH="${BBR_ARTIFACT_DIRECTORY}/postgres_${dbname}.sql"
2833
if [ -f "${BBR_ARTIFACT_FILE_PATH}" ]; then
@@ -41,6 +46,7 @@ for dbname in ${DATABASES[@]}; do
4146
--use-list=${TMP_LIST_FILE} \
4247
--if-exists \
4348
--clean \
49+
${SINGLE_TRANSACTION} \
4450
"${BBR_ARTIFACT_FILE_PATH}"
4551
else
4652
echo "WARNING: Not restoring ${dbname} because backup file ${BBR_ARTIFACT_FILE_PATH} does not exist"

0 commit comments

Comments
 (0)