Skip to content

Instantly share code, notes, and snippets.

@rduplain
Last active December 13, 2015 17:18
Show Gist options
  • Save rduplain/4946399 to your computer and use it in GitHub Desktop.
Save rduplain/4946399 to your computer and use it in GitHub Desktop.
Prevent stop/restart of postgresql on Debian/Ubuntu. Do so carefully while watching updates, and restart manually.
#!/bin/sh
# /usr/sbin/policy-rc.d
# Do not stop/restart postgresql. --rduplain 2013-02-13
# http://askubuntu.com/a/254307/113086
if [ "$1" = "postgresql" ]; then
# Forbid stop/restart, or any init action for that matter.
# 101 - action forbidden by policy
exit 101
fi
@webervin
Copy link

webervin commented May 1, 2015

@polobo:
for first part of your question: there is second argument "action", you can add second check, so 101 is returned only for "stop" and "restart", while "start" and "reload" will continue to work, so you can keep policy on server forever.

Second and third questions are more tricky:
http://www.postgresql.org/docs/devel/static/upgrading.html states: To update between compatible versions, you simply replace the executables while the server is down and restart the server. The data directory remains unchanged — minor upgrades are that simple.

so currently upgrade routine follows documentation (keeping data safe). Maybe in future, there will be "better" upgrade procedure, doing something similar to nginx (http://nginx.org/en/docs/control.html#upgrade), which probably will be issue with memory / resident set / caches.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment