Hibou Roost - Odoo: Odoo Database Management: Major Version Upgrades
Purpose
This document offers guidance and resources needed with major Odoo version upgrades.
Resources
Odoo Enterprise
Odoo Enterprise comes with upgrade support. You can use the form at https://upgrade.odoo.com/upload to create upgrade requests.
Hibou Flow
Odoo has an 'upgrade' script that allows you to use CLI tools pg_dump, ssh, and rsync to create, upload, see the running upgrade, and ultimately download the upgraded database.
Hibou Flow includes a modified/upgraded version of this script (supporting restart of the upload/download and locations relevant to our pipeline built containers).
To utilize it you will need to exec a shell AND keep that shell up or be ready to 'restart' it if the shell closes early. There are key steps that you must interact with (e.g. to say 'yes'), so unlike other flow scripts, this one cannot be run and "walked away from".
Additionally, unlike other flow scripts, there is some 'setup' as these variables are not setup by flow itself (to keep it more like the original Odoo script).
In the example below, 'test' is the reason for the upgrade request, 'production' would be the other. -t 14.0 is the 'target odoo version' -c M151230001234 is the customer's Odoo subscription code.
# Setup
export PGHOST=db
export PGPORT=5432
export PGUSER=odoo
export PGPASSWORD=odoo_db_pass
cd /flow/odoo/scripts/
# Actual command
./upgrade.py test -d prod13 -t 14.0 -c M151230001234
Wrapped Declarative version!
The following code is essentially the same as the above code, but has the added benefit of answering 'yes' to questions and attempting retries on rsync errors.
Note that the 'test' above is the default!
The output of this should have RESTORED AS prod13-test-${DATE}
/entrypoint.sh flow odoo-upgrade -d prod13 -t 14.0 -c M15100000123
Wrapped Declarative version!
Additional added features include the fact that you can now declare the database, here is a production example with the ability to increase or reduce the number of rsync (or other exit code) retries.
NOTE: as of today, 04/29/2022, the Enterprise code can be fetched out of the database and (-c) is no-longer required. It will be used if present though.
This time it should end with RESTORED AS prod14
If you experience any uncaught errors that need retry, please provide example logs.
/entrypoint.sh flow odoo-upgrade -d prod13 \
--type production \
-t 14.0 \
-c M15100000123 \
--resume_count 4 \
--restore_db_name prod14
Openupgrade
Openupgrade is a community supported upgrade option. Hibou has images that can be swapped as either the base for builds, or more likely, swapped out as the main image for the duration of an upgrade.
registry.gitlab.com/hibou-io/hibou-odoo/openupgrade:12.0
The typical workflow would be to take a 'working' database from the immediately prior version (e.g. 11.0) and then applying 'base' upgrades from the image. Some important things to note when using this method.
* Config files must not include 'addons' directories that do not exist.
* This process is destructive and should only be performed in a 'backup' environment.
* The result of this process can be used locally, but typically would be immediately backed up somewhere to be restored.
# Start with a working odoo11 database with filestore.
# edit docker-compose.yml or environment to use the 12.0 image
# registry.gitlab.com/hibou-io/hibou-odoo/openupgrade:12.0
docker-compose run --rm odoo -- -d odoo11 -u base --stop-after-init
# OR exec a shell
odoo -d odoo11 -u base --stop-after-init --no-xmlrpc
# If you need to go to 13, repeat the above process with the 'next' image.
# Typically you will need to use psql to make database specific fixes