-
Notifications
You must be signed in to change notification settings - Fork 314
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
Read PostgreSQL port from PGDATA folder #340
base: master
Are you sure you want to change the base?
Conversation
50b95b9
to
3f04ee5
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Clever idea, all in all. What do you think about checking show data_directory
to find and/or use a matching cluster?
wal_e/operator/backup.py
Outdated
@@ -172,10 +172,18 @@ def database_backup(self, data_directory, *args, **kwargs): | |||
if 'while_offline' in kwargs: | |||
while_offline = kwargs.pop('while_offline') | |||
|
|||
port = None | |||
if not while_offline: | |||
postmaster_pid = open(os.path.join(data_directory, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Use the with
statement to do open/close.
This should be overriden by a |
Using a PGPORT environment variable is the usual way, but since the documentation never mentions it and the information is in the PGDATA folder, one could (wrongly) assume it was not required. Do you suggest I add a check that psql connects to the server that has the right data_directory ?
And if PGPORT is not specified in environment, continue extracting it from data directory and put it in env ? |
I do suggest such check. Sorry for the delay. |
Mr. PierreDucroquet, could you mention in your blog http://www.pinaraf.info/2017/06/wal-e-and-the-gotcha-how-i-nearly-lost-50-of-my-backups/, |
@zvolsky No offense, but I do mention that you can put the PGPORT in the environment variables. I do not say that wal-e has a bug (grep for that word, you will not find it) but instead a "gotcha", a tiny trap that is never mentioned anywhere in the documentation nor the code and that is misleading since the port can be found in the PGDATA folder. Please point out specifically what bother you in that blog post which main aim was to be informative and point out a serious trap that at least some of my DBA friends were not aware of. |
3f04ee5
to
4476ad8
Compare
This checks the PGPORT environment variable for consistency with the PGPORT reported by the PostgreSQL cluster.
4476ad8
to
99dbbd0
Compare
@fdr I have rewritten the patch as you suggested, removing the extra parameter and instead just checking for consistency. |
Reviving old threads. I think this looks good but fails some stylechecks, etc. @PierreDucroquet do you mind rebasing this and fixing the test errors? I am happy to merge this right after that. If not that's fine, I might just do it myself and give you the credit. :) It seems like the |
Hi
During a routine check of my backups, I found out that wal-e does its base backup using psql with no parameter, thus using only the default cluster. Since I have several PostgreSQL versions on the same server, it means that the backups are complete only for the default one.
That behaviour is not documented and easy to fix by reading postmaster.pid and extracting the cluster port from that file.
This patch implements this behaviour.
Ref #326