BCDevOps / backup-container

A simple container for a simple backup strategy.
Apache License 2.0
42 stars 56 forks source link

Fix to add declare the port parameter of the psql command #55

Closed garywong-bc closed 4 years ago

garywong-bc commented 4 years ago

Noticed that these commands (in the current version of psql) returned errors such as:

Example 1:

sh-4.2$ psql -h "${_hostname}" ${_portArg} -ac "DROP DATABASE \"${_database}\";"
Password: 
psql: FATAL:  database "5432" does not exist

Example 2:

sh-4.2$ gunzip -c "${_fileName}" | psql -v ON_ERROR_STOP=0 -x -h "${_hostname}" ${_portArg} -d "${_database}"
Password for user 5432: 

So this PR explicitly denotes the 'port' parameter in the psql commands.

garywong-bc commented 4 years ago

@WadeBarnes I think this worked in the past when the port # was unspecified so ${_portArg} was null and didn't impact the psql commands.

WadeBarnes commented 4 years ago

That's what this line does; https://github.com/BCDevOps/backup-container/blob/master/docker/backup.postgres.plugin#L58.

If the port number is specified, 5432 for example, the value of ${_portArg} becomes -p 5432. Otherwise ${_portArg} is blank, which tells psql to use the default port.

garywong-bc commented 4 years ago

Ah.. I missed that.. please ignore.