Ubuntu – Prevent postgresql from restarting via automatic updates

aptpostgresqlunattended-upgrades

I know I could probably do the following:

How to prevent updating of a specific package?

And prevent postgresql from upgrading altogether. But then if I want to upgrade it manually I would have to unhold the following packages and then hold them again:

postgresql-9.3 install
postgresql-client-9.3 install
postgresql-client-common install
postgresql-common install

which is a bit of a pain to do if you are managing several servers. Meaning I would have to write scripts for this purpose and such.

The ideal solution here would be the following:

unattended upgrades will update the packages but do not restart postgresql, or, unattended security upgrades don't upgrade the packages but doing a manual apt-get dist-upgrade does without having to hold and unhold.

Is there any way to do this with a bit more finesse than the original suggestion?

Reason being that when I upgrade our servers, any service is okay to interrupt for a second, but when you interrupt a database, bad things can happen.

Best Answer

With the unattended-upgrades package, you can blacklist packages you do not wish it to upgrade.

Not sure how deep down the dependency tree this goes.

See: Ubuntu: Automatic Updates

// List of packages to not update (regexp are supported)
Unattended-Upgrade::Package-Blacklist {
        "postgresql-.*";
//      "vim";
//      "libc6";
//      "libc6-dev";
//      "libc6-i686";
};

`