Skip to content

Commit 3ff25be

Browse files
committed
Add pgdump-args option to save command
1 parent ac112f8 commit 3ff25be

File tree

3 files changed

+11
-4
lines changed

3 files changed

+11
-4
lines changed

commands/common.sh

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ parse_options() {
8686

8787
# Options and long options
8888
local options="h:p:U:d:W:"
89-
local longopts="host:,port:,username:,dbname:,password:,password-file:,no-create-database,no-revoke-public-create,drop-database,format:,compression:,umask:,skip-globals,skip-database:,skip-analyze,full-count,aws-args:"
89+
local longopts="host:,port:,username:,dbname:,password:,password-file:,no-create-database,no-revoke-public-create,drop-database,format:,compression:,umask:,skip-globals,skip-database:,skip-analyze,full-count,aws-args:,pgdump-args:"
9090
local parsed
9191

9292
# Parse with getopt (not getopts)
@@ -162,6 +162,10 @@ parse_options() {
162162
IFS=$' \n\t' read -r -a aws_args <<<"${2}"
163163
shift 2
164164
;;
165+
--pgdump-args)
166+
IFS=$' \n\t' read -r -a pgdump_args <<<"${2}"
167+
shift 2
168+
;;
165169
--)
166170
shift
167171
break

commands/save

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ usage() {
2727
global_options
2828
echoerr ""
2929
echoerr "Options:"
30-
echoerr " --pgdump-args NOT IMPLEMENTED"
30+
echoerr " --pgdump-args OPTIONS"
3131
echoerr " --aws-args OPTIONS"
3232
echoerr " --format plain|custom"
3333
echoerr " --compression gzip|lz4|bz2|none"
@@ -53,6 +53,9 @@ unset "args[-1]"
5353
umask "${umask:-0077}"
5454

5555
date="$(date --utc "+${date_format:-%Y%m%d%H%M%S}")"
56+
# Undocumented feature to allow overriding the date.
57+
# Useful when using offloaded backup so the actual snapshot date can be used.
58+
date="${OVERRIDE_DATE:-${date}}"
5659

5760
case "${dest}" in
5861
gs://*)
@@ -77,7 +80,7 @@ case "${dest}" in
7780
;;
7881
esac
7982

80-
cmd_args=()
83+
cmd_args=( "${pgdump_args[@]}" )
8184
file_ext=()
8285
file_path=( "${dest}" "${date}" )
8386

tests/save.bats

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ teardown_file() {
3232
-e DATABASE_USERNAME=postgres \
3333
-e DATABASE_PASSWORD=password \
3434
-v "${working_volume}:/db-dumps" \
35-
"${TOOLBOX_IMAGE}" save --umask 022 /db-dumps
35+
"${TOOLBOX_IMAGE}" save --umask 022 --pgdump-args "--compress 0" --format custom /db-dumps
3636
diag "${output}"
3737
[[ "${status}" -eq 0 ]]
3838
}

0 commit comments

Comments
 (0)