Server and module updates
Once the Odoo server is up-and-running, you'll need to install updates on Odoo. This involves two steps—getting new versions of the source code (for the server or modules) and installing them.
If you have followed the approach described in the Installing from the source code section correctly, you should now be able to fetch and test new versions of source code in the staging repository. It's strongly advised that you make a copy of the production database and test any upgrades on it. If
odoo-prod is your production database, an odoo-stage copy can be created with the following commands:$ dropdb odoo-stage
$ createdb --owner=odoo odoo-stage
$ pg_dump odoo-prod | psql -d odoo-stage
$ sudo su odoo
$ cd ~/.local/share/Odoo/filestore/
$ cp -al odoo-prod odoo-stage # create filestore hardlinks
$ exit
Before we can use the preceding copy of the database, cleanup should be done, such as deactivating scheduled actions, and email servers (both for sending and fetching messages). The specific steps needed here depend on your setup, but it's likely they can be automated by a script. Remember that the
psql command can be used to run SQL directly from the command line, such as psql -d odoo-stage -c "<SQL command>".
To get the latest Odoo source code from the GitHub repository, we use the
git pull command. Before doing that, we can use the git tag command to create a tag for the current commit in use, so that it's easier to revert the code update, as follows:$ sudo su odoo
$ cd ~/odoo-12
$ git tag --force 12-last-prod
$ git pull
For code changes to take effect, we need to restart the Odoo service. For data file changes to take effect, an upgrade to the modules is needed. As a general rule, changes to Odoo stable versions are considered code fixes, and it's therefore not often worth the risk of performing module upgrades. If you need to perform a module upgrade, however, it can be achieved using the
-u <module> additional option, or -u base, which upgrades all modules.
Now it's time to start the Odoo staging server, which will use the update code on it staging database, as follows:
$ ~/odoo-12/odoo-bin -d odoo-stage --http-port=8080 \
-c /etc/odoo/odoo.conf # optionally add: -u base
$ exit
This Odoo staging server was configured to listen on the
8080 port. We can navigate there with our web browser, using an address such as http://localhost:8080, to check whether the upgraded code works correctly.
If something goes wrong, we can revert the code to an earlier version with the following code:
$ sudo su odoo
$ cd ~/odoo-12
$ git checkout 12-last-prod
$ exit
If everything works as expected, it should be safe to perform an upgrade on the production service, which is usually done by restarting it. If you want to perform an actual module upgrade, the suggested approach is to stop the server, run the upgrade, and then restart the service, as follows:
$ sudo service odoo stop
$ sudo su -c "~/odoo-12/odoo-bin -c /etc/odoo/odoo.conf" \
" -u base --stop-after-init" odoo
$ sudo service odoo start
Remember to make a note of the Git reference in use by checking out the necessary version. This will enable you to rollback any changes if necessary. Keeping a backup of the database before an upgrade is also highly advised.
After this is complete, we can pull the new versions to the production repository using Git and complete the upgrade as follows:
$ sudo su odoo
$ cd ~/odoo-12
$ git tag --force 12-last-prod
$ git pull
$ exit
$ sudo service odoo restart # or: sudo systemctl restart odoo
There's no point in updating too frequently, but it's not advised that you wait a year between updates either. Performing an update every few months is usually fine. Also note that a server restart should be enough to enable code updates—and that module upgrades aren't always necessary.
If you need a specific bug fix, however, an earlier update should be considered. Remember to also watch out for security bug disclosures on public channels such as GitHub Issues for Odoo, in particular, ones displaying the Securitytag, at https://github.com/odoo/odoo/issues?q=is%3Aissue+label%3ASecurity, or the Odoo official mailing lists, which can be subscribed to at https://www.odoo.com/groups.
As part of the service, enterprise contract customers can expect early email notifications alerting them to this type of issue.
Comments
Post a Comment