Was created to provide upstream image w/ cron extension pre-installed. Problem with this is tho that this extension can only be created in a single database, thus limits number of apps that can access it, or at least makes the coordination more complex. For split-pro app we went with separate postgres instance instead.
Also note there's no real need for the init script, as the extension can simply
be installed from the psql command line (i.e. same command we run from the
included init script), and afterwards the create statement will be included
in the db dump. So the only real value provided by this image would be the
apt-installed postgresql-<ver>-cron package.
Provides an upstream postgres image with cron extension preinstalled
For the upstream Dockerfile, see here
Note
For the initial startup, make sure to add required options to cmd, as by this
point we haven't yet restored postgres.conf file that includes these keys:
postgres -c shared_preload_libraries=pg_cron -c cron.database_name=postgres
If not, the init script will likely error, but as database is initialized, then on the subsequent restarts the init scripts no longer run, as described in our init file header.
-
option 1: use pg_upgrade
-
option 2: via
pg_dumpalldocs- supposedly safer
-
note docs mention:
Though you can upgrade from one major version to another without upgrading to intervening versions, you should read the major release notes of all intervening versions
Does that imply we can upgrade from say v15->18, or does it mean no need to do the intervening minor versions?
- recommended to use
pg_dump*programs from the newer version, but so far I've been ignoring it and dumping w/ the pg_dump from old container.
- either stop all services using db, or disable their access (or do both!):
nvim /mnt/user/appdata/postgres/pg_hba.conf- sroll to the bottom
- change all entries'
METHODvalue fromtrusttorejectthat do not start withlocal- likely just changing the last line
host all all all scram-sha-256tohost all all all rejectshould suffice, as long as it's the only rule that applies to non-local connections
- likely just changing the last line
- restart container/server
- ssh/dbash to our pgres container
- run
pg_dumpall -U postgres > "/config/dumpall-$(date '+%Y-%m-%d_%R')"; echo $? - stop the server/container
- on host, rename our postgres dir:
mv /mnt/user/appdata/postgres /mnt/user/appdata/postgres.old - upgrade image to next version
- start the container/service
- restore
pg_hba.conf&postgresql.conf- optionally diff them from host beforehand:
vimdiff /mnt/user/appdata/postgres.old/postgresql.conf /mnt/user/appdata/postgres/postgresql.confvimdiff /mnt/user/appdata/postgres.old/pg_hba.conf /mnt/user/appdata/postgres/pg_hba.conf- make sure not to revert access restriction yet!
cp /mnt/user/appdata/postgres.old/{postgresql.conf,pg_hba.conf} /mnt/user/appdata/postgres/
- optionally diff them from host beforehand:
- restart the container
- on host, move dump to new dir:
cp /mnt/user/appdata/postgres.old/dumpall-* /mnt/user/appdata/postgres/ - restore data:
psql -d postgres -U postgres -f /config/dumpall-???; echo $? - revert our modifications to
pg_hba.conf - restart
- nuke dump:
rm /mnt/user/appdata/postgres/dumpall-* - if all good, nuke our old backup:
rm -r /mnt/user/appdata/postgres.old
TODO