Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

could not translate host name "localhost:5432" to address #1

Closed
babvin opened this issue Aug 26, 2019 · 2 comments
Closed

could not translate host name "localhost:5432" to address #1

babvin opened this issue Aug 26, 2019 · 2 comments

Comments

@babvin
Copy link

babvin commented Aug 26, 2019

ben@debian:postgres-backup-container$ docker run -v /backup:/pg_backup babvin/postgres-back-up
Creating dump: backupOn2019-08-26-18-22.dump
pg_dumpall: could not connect to database "template1": could not translate host name "localhost:5432" to address: Name does not resolve Back up not created, check db connection settings
ben@debian:postgres-backup-container$

ben@debian:postgres-backup-container$ cat dumpDatabase.sh
DUMP_FILE_NAME="backupOndate +%Y-%m-%d-%H-%M.dump"
echo "Creating dump: $DUMP_FILE_NAME"

cd pg_backup

PGPASSWORD=password pg_dumpall -U postgres > $DUMP_FILE_NAME

if [ $? -ne 0 ]; then
rm $DUMP_FILE_NAME
echo "Back up not created, check db connection settings"
exit 1
fi

echo 'Successfully Backed Up'
exit 0
ben@debian:postgres-backup-container$

ben@debian:postgres-backup-container$ cat Dockerfile
FROM alpine:3.6

ENV PGHOST='localhost:5432'
#ENV PGHOST='192.168.99.101'
ENV POSTGRES_PORT=5432
ENV PGDATABASE='postgres'
ENV PGUSER='postgres@postgres'
ENV PGPASSWORD='password'

RUN apk update
RUN apk add postgresql

COPY dumpDatabase.sh .

ENTRYPOINT [ "/bin/sh" ]
CMD [ "./dumpDatabase.sh" ]
ben@debian:postgres-backup-container$

@luisg0nc
Copy link
Contributor

Use PGHOST only for the hostname/ip and add PGPORT for the port.
Tested and it works.

@rinormaloku
Copy link
Owner

Solved with the #2 PR

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants