Skip to content

Commit 9302bab

Browse files
committed
Add support for skip databases on save
1 parent 9063924 commit 9302bab

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed

commands/common.sh

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ global_options() {
3636
echoerr " -d|--dbname database to connect to"
3737
echoerr " -W|--password password to connection to (not recommended. Use password-file)"
3838
echoerr " --password-file password file to read password from"
39+
echoerr " --skip-database databases to skip"
3940
}
4041

4142
parse_options() {
@@ -73,6 +74,16 @@ parse_options() {
7374
fi
7475
done
7576

77+
# Pull in environment variables prefixed with TOOLBOX_
78+
# TOOLBOX_SKIP_DATABASES should be comma separated
79+
for item in skip_databases; do
80+
local varname
81+
varname="TOOLBOX_${item^^}"
82+
if [[ -n "${!varname:-}" ]]; then
83+
eval ${item}="${!varname}"
84+
fi
85+
done
86+
7687
# Options and long options
7788
local options="h:p:U:d:W:"
7889
local longopts="host:,port:,username:,dbname:,password:,password-file:,no-create-database,no-revoke-public-create,drop-database,format:,compression:,skip-globals,skip-database:,skip-analyze,full-count"
@@ -190,6 +201,11 @@ parse_options() {
190201
umask "${old_umask}"
191202
echoerr ">>> Password written to ${PGPASSFILE}"
192203
fi
204+
205+
# If skip_databases was set, split into an array
206+
if [[ -n "${skip_databases:-}" ]]; then
207+
IFS=',' read -r -a skip_databases <<< "${skip_databases}"
208+
fi
193209
}
194210

195211
echoerr() { echo "$@" 1>&2; }

0 commit comments

Comments
 (0)