Skip to content

Commit

Permalink
[F] Support both .pgpass and --no-password pg_dump
Browse files Browse the repository at this point in the history
  • Loading branch information
Clark Burns committed Dec 17, 2018
1 parent 82e22de commit 17f662c
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 3 deletions.
2 changes: 1 addition & 1 deletion add-config
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ main() {
echo "Database user:"
read database_user

echo "Database password:"
echo "Database password (use .pgpass if using PostgreSQL but supply arbitrary value here):"
read -s database_password

cat << CONFIG
Expand Down
9 changes: 7 additions & 2 deletions donut
Original file line number Diff line number Diff line change
Expand Up @@ -128,10 +128,15 @@ main() {
echo "" > ${tmp_db_config}
;;
postgresql)
if [ -z ${password} ]; then
password="--no-password"
else
password=""
fi
if [ -z ${host} ]; then
pg_dump -U${user} --no-password ${schema} > ${backup_file}
pg_dump -U${user} ${password} ${schema} > ${backup_file}
else
pg_dump -h${host} -U${user} --no-password ${schema} > ${backup_file}
pg_dump -h${host} -U${user} ${password} ${schema} > ${backup_file}
fi
;;
*)
Expand Down

0 comments on commit 17f662c

Please sign in to comment.