This question has been flagged
3 Replies
13144 Views

Hello,

As of the subject, how to correctly upgrade our openerp server? Until now usually I do like this 1. download the newest version 2. stop the openerp server => /etc/init.d/openerp stop 3. remove the openerp => apt-get remove openerp 4. install the new version => gdebi opernerp.... Currently I'm using Ubuntu 12.04. Is that the best way to upgrade or maybe any other suggestion? Thanks...

Avatar
Discard
Best Answer

you can use bzr as follows:

TO INSTALL:

sudo apt-get install bzr

sudo su – openerp

cd /opt/openerp

bzr branch lp:openobject-server/7.0 server

bzr branch lp:openobject-addons/7.0 addons

bzr branch lp:openerp-web/7.0 web

TO UPDATE

sudo /etc/init.d/openerp-server stop

sudo su - openerp -s /bin/bash

cd /opt/openerp/addons/

bzr pull

cd /opt/openerp/web/

bzr pull

cd /opt/openerp/server/

bzr pull

Check this for full installation:

Check question 2562 how-to-install-openerp-v70-on-ubuntu-1204-from-launchpad-repository

I can't post link due to Karma limitation.

Avatar
Discard
Best Answer

Upgrading has two steps:

  1. The source code
  2. The database(s)

This is a script one of our clients, Logic Supply, uses to upgrade the code and the databases:

#!/usr/bin/env python
# update-branches
# Author:       Brendan Clune
# Description:  Updates the server, web, and addons branches of
#               OpenERP and records their previous revision numbers
#               in a timestamped update log.

from datetime import date
import subprocess, xmlrpclib, sys, os, psycopg2, pexpect

# Database info
db_user = '<your credentials>'
db_passwd = '<your credentials>'
db_host = '<your server>'
db_port = 5432
db_name = 'postgres'
oerp_conf = '<path to your configuration file>'
oerp_bin = "<path to openerp-server branch folder>/openerp-server"

today = date.today()
log_date = today.strftime('%Y%m%d')
log_name = "branch-update-{}.log".format(log_date)
base_dir = os.getcwd()

with open(log_name, 'a+') as log_file:
  for branch in ["server", "web", "addons"]:
    # Get revision number
    rev_cmd = ["bzr", "revno", branch]
    try:
      rev_no = subprocess.check_output(rev_cmd, stderr=subprocess.STDOUT).strip()
    except subprocess.CalledProcessError as e:
      print "Error invoking bzr revno: {}".format(e.strerror)
    status = "Pulling latest {} revision (currently {}).".format(branch, rev_no)
    print status
    log_file.write(status + "\n")

    # Update branch
    update_cmd = ["bzr", "pull"]
    try:
      os.chdir(branch)
      status = subprocess.check_output(update_cmd, stderr=subprocess.STDOUT).strip()
    except subprocess.CalledProcessError as e:
      print "Error invoking bzr update: {}".format(e.strerror)
    os.chdir(base_dir)
    print status
    log_file.write(status + "\n")

  # Get list of databases
  db = psycopg2.connect(user=       db_user, 
                        password=   db_passwd,
                        host=       db_host,
                        port=       db_port,
                        database=   db_name)
  cr = db.cursor()
  cr.execute("select datname from pg_database where datdba=(select usesysid from pg_user where usename='{}') order by datname".format(db_user))
  dblist = [str(name) for (name,) in cr.fetchall()]

  for database in dblist:
    # Wait for server to upgrade database, then kill it
    print "Upgrading database {}...".format(database)
    dbupdate_cmd = "{} -c {} --database={} --update=all".format(oerp_bin, oerp_conf, database) 
    output = pexpect.spawn(dbupdate_cmd)
    try:
      output.expect('.*OpenERP server is running, waiting for connections...', timeout=600)
    except pexpect.ExceptionPexpect as e:
      print "Timeout reached while upgrading {}. Try manually upgrading the database with the command '{}'.".format(database, dbupdate_cmd)
    output.kill(0)

    status = "Upgraded database {}.".format(database)
    print status
    log_file.write(status + "\n")
Avatar
Discard
Author

Thanks for the code... anyway, may I know what kind of file extention it will be and how do I run it?

It is a Python script.

Wooooowww! To Pyromaniac like me! this is a box of matches and a window into another world...burn baby burn! :)))))

Just a heads up; you'll want to install the Python module 'pexpect' to make everything work. 'sudo easy-install pexpect' should do the trick! You'll want to leave it at the root of your OpenERP folder and run it from there, or adjust the paths accordingly.

Author

Hai... if for example I backup my current database... then remove the current openerp and install the lastest one.. After that I restore the database. As of the information above, the database upgrade will or will not be perform? IF NOT... then the backup database feature is just useless then? Thanks...

Yes. Backup works for keeping a copy of your database in case you need to restore it on the same version (the usual benefit of a backup) as well as for migrating/upgrading between minor versions of OpenERP (ie: from 6.1 March to 6.1 November or from 7.0 December to 7.0 March) when you use the --update=all command-line argument. You cannot migrate between major versions (ie: from 6.1 to 7.0) using this method.

Best Answer

you can use bzr tool to pull from lauchpad...when you upgrade just use "bzr pull"

Avatar
Discard