Upgrading iDempiere

The purpose of this page is to help you upgrade iDempiere. Please note these steps do not apply to ADempiere. I use virtualization when hosting my iDempiere servers; therefore, my approach might be different than yours if you host on-site. Generally, I do not let any server live for more than about one year. When I upgrade iDempiere, I do not upgrade the server, I replace it with a newly installed and updated server. The concept of replacing has the following benefits: Here are the instructions for replacing an all-in-one iDempiere instance:
  1. Create a new Ubuntu instance
  2. Run the current Chuboe installation script as if you were installing iDempiere from scratch
  3. Create a DB backup of your old server (see tutorial)
  4. Copy your old DB backup to the new server
  5. Restore your old DB backup on the new server (see tutorial)
  6. Run the /opt/chuboe/.../utils/chuboe_idempiere_upgrade.sh -s script on the new server to upgrade your old DB to contain the newest changes (note: the -s indicates that the binaries do not need upgrading - just he BD)
  7. Deploy all plugins on your new server
Notes about when you have separate iDempiere servers and databases: IMPORTANT NOTE: Always perform the below actions on a test server before performing it on a production server to ensure you get the desired results and to ensure you have a valid backup plan in case things go wrong.

iDempiere Upgrade

2015-04- 27 How to Revert iDempiere Including Binaries and Database

Manually Upgrading Your Server

Step 1 - Upgrade Your Binaries

When you use my script to install iDempiere, the installation directory is /opt/idempiere-server. In this directory, you will find a script named update.sh. You use this script to upgrade your iDempiere to what ever version you point this script to. If you are wanting to upgrade to the most recent version from the official iDempiere build server, point your script here. If you have created your own build, point the script to your build's site.p2 directory. Here are the commands to upgrade your iDempiere binaries. For some reason, the first time I run the update.sh command, I get an error relating to a folder not existing. The second time I run it, all goes well. I have asked the development team about this topic.
sudo service idempiere stop
Please note that the below URL will change over time. You can go to jenkins.idempiere.com and browse to the correct iDempiere job and server version to confirm the current path.
./update.sh http://jenkins.idempiere.com/job/iDempiere/ws/buckminster.output/org.adempiere.server_2.0.0-eclipse.feature/site.p2/
Don't do this yet... sudo service idempiere start
Note that you do not want to start your server yet. There could be a material difference between your newly installed code and database's application dictionary. We will upgrade the database in the next step.

Step 2 - Upgrade your Database

Your database needs to be in sync with your code. Unfortunately, there is no 'really' easy way to manage database changes. It is not hard; however, it is just not easy. Every time developers make a change to code that relies on an application dictionary change, they create a SQL script. Over time, the project will create a large number of SQL scripts to go from the base version (say 2.0) to the current development version. You can see the list here. For version 2, look in the folders i2.0 and i2.0z. You have two options when upgrading your database.
  1. The manual applying of SQL scripts
  2. The automated applying of SQL scripts
In the manual option of applying database upgrade script, you do the following:
  1. Look in the ad_migrationscript table to see what scripts have already been applied. (select name from ad_migrationscript).
  2. Look in the current version's script folder (here) to see what is outstanding.
  3. Copy, paste into phppgadmin, execute, copy, paste into phppgadmin, execute, etc....
  4. You can see how this would get very old very quickly.
In the automated version of applying database upgrade scripts, you do the following:
  1. Download Carlos Ruiz's script to automate applying database update scripts.
  2. Update your /etc/postgresql/x.x/main/pg_hba.conf file to trust local connections so that you do not need to enter your password 100'ish times. (see below)
  3. Run Carlos's script
  4. Update your pg_hba.conf file back to md5 (see below)
Before you begin, it is worth mentioning that once you update your database, there is no way to unupdate it. In other words, there is no un-install script. Instead you must restore from a backup. To backup your database, RUN_DBExport.sh.
cd /opt/idempiere-server/utils/
./RUN_DBExport.sh
Update the database so that is does not ask you for your password 100'ish times. Please note this command assumes you are connecting to the database locally.  If you plan to run your upgrade script from one machine against a database on another machine, you will need to modify a different line in pg_hba.conf. Please note the below command is one statement. You need to copy and paste the whole thing.
sudo sed -i 's|host    all             all             127.0.0.1/32            md5|host    all             all             127.0.0.1/32            trust|' /etc/postgresql/9.1/main/pg_hba.conf
Restart the database to make the config change active
sudo service postgresql restart
Download Carlos' script
wget https://bitbucket.org/CarlosRuiz_globalqss/idempiere-stuff/raw/tip/script_to_sync_db/syncApplied.sh
Change the permissions on Carlos' script
chmod 766 syncApplied.sh
Run Carlos' script.  My migration folder happened to be in /home/ubuntu/migration. Yours will probably inside your source code repository. If you do not have the source downloaded, and you are wanting to upgrade your server to the latest bleeding version, you can download the latest migration scripts here. The steps to download the migration scripts include (1) perform a wget on this link, (2) unzip, and (3) point the below command to unzipped migration folder.
./syncApplied.sh idempiere "-h localhost" /home/ubuntu/migration
Update the database config file to always ask users for their password when connecting. Please note the below command is one statement. You need to copy and paste the whole thing.
sudo sed -i 's|host    all             all             127.0.0.1/32            trust|host    all             all             127.0.0.1/32            md5|' /etc/postgresql/9.1/main/pg_hba.conf
Restart the database to make the config change active
sudo service postgresql restart
Start the iDempiere server.
sudo service idempiere start
That is it!!! If for some reason you are not happy with the above process, you can restore your database from your previous database backup by using the following commands. NOTE: ONLY RUN THIS IF YOU ARE NOT HAPPY WITH THE ABOVE RESULTS!
sudo service idempiere stop
cd /opt/idempiere-server/utils/
./RUN_DBRestore.sh