Upgrade to a new version of elasticsearch
Change the default elasticsearch version for a module
- Individually upgrade all hosts to the new version, following the processes below.
- Change the default value of the
elasticsearchTag
option for the module. - Remove the per-host
elasticsearchTag
options.
Upgrade to a new minor version
This is generally safe. Just change the elasticsearchTag
and rebuild the NixOS
configuration.
Upgrade to a new major version
In brief: take a backup, upgrade to the latest minor release of the current major version, fix any application warnings, and then upgrade to the initial release of the new major version.
Shell variables:
$VOLUME_DIR
- the directory on the host that the container's/usr/share/elasticsearch/data
is bind-mounted to
-
Upgrade to the latest minor release of the current major version.
-
Change the
elasticsearchTag
option in the host's NixOS configuration to the latest minor release of the current major version. -
Rebuild the NixOS configuration and check that the database and all of its dependent services come back up:
sudo nixos-rebuild switch
-
-
Exercise the application, performing both reads and writes: check the elasticsearch log for deprecation warnings, and fix any issues in the application.
-
Stop the database.
-
Take a backup:
sudo cp -a "$VOLUME_DIR" "${VOLUME_DIR}.bak"
-
Change the
elasticsearchTag
option in the host's NixOS configuration to the initial release of the new major version. -
Rebuild the NixOS configuration and check that the database and all of its dependent services come back up:
sudo nixos-rebuild switch
Rollback
The old database files are still present at ${VOLUME_DIR}.bak
, so:
-
Stop all the relevant services, including the database container.
-
Restore the backup:
sudo mv "$VOLUME_DIR" "${VOLUME_DIR}.aborted" sudo mv "${VOLUME_DIR}.bak" "$VOLUME_DIR"
-
If the
elasticsearchTag
has been updated in the NixOS configuration:- Revert it to its previous version.
- Rebuild the NixOS configuration.
-
Restart all the relevant services.