Nach oben: Guix System Management   [Inhalt][Index]


10.1 Upgrade Postgres for Cuirass

With the deprecation of the default value for the postgres package in postgresql-configuration (see b93434e656eba4260df82158a96c295000d3ff44), system upgrades need some manual action before they can take place. Here’s a handy guide on how to.

Please note that this is a straight-forward way for smaller datasets. For larger databases pg_upgrade may be the better choice. Handling the service and system upgrade as described in this guide still applies, though.

  1. Stop and disable cuirass.

    Prevent the service from starting and failing after a reconfiguration:

    sudo herd stop cuirass && sudo herd disable cuirass

  2. Dump the database contents.

    sudo su - postgres -s /bin/sh -c pg_dumpall > /tmp/pg.dump

  3. Add or alter the postgres service.

    Depending on whether your postgres service is defined implicitly (through the dependency from the cuirass service) or its own entry in your operating system’s (services) property, you need to either add or alter the already existing configuration to reflect your intended version upgrade.

    Be careful not to upgrade directly to postgres-16 – cuirass service for some reason doesn’t like that. I had to find and purge the relevant files and then re-initialize after a failed upgrade to postgres 16.

    (service postgresql-service-type
             (postgresql-configuration
              (postgresql ( (gnu packages databases) postgresql-15))))
    

    Note: If you for some reason didn’t read the text here but somewhat blindly followed the examples and did upgrade to 16, here’s how you reset the state:

    1. Delete the database instance files.

      They default to live under /var/lib/postgres/data.

    2. Re-initialize postgres.

      sudo su - postgres -s /bin/sh -c 'pg_ctl init -D /var/lib/postgres/data'

  4. Reconfigure your system.

    sudo guix system reconfigure path/to/your/altered/config.scm

  5. Restore database contents.

    sudo su - postgres -s /bin/sh -c 'psql -d postgres -f /tmp/pg.dump'

  6. Enable and start the service.
    sudo herd enable cuirass
    sudo herd start cuirass
    

Nach oben: Guix System Management   [Inhalt][Index]