Question About Servers

How to Migrate Your Odoo Instance to a Different Server Print

  • 43

This guide covers all the necessary steps required to migrate Odoo from one server to another (Ubuntu). 


Odoo Migration

The example below assumes that you are migrating a live version from the production server to a development server.

NOTE: The production instance is consistently named. For example, Odoo 11 instance will be named odoo11-live (linux user, /opt directory, configuration file, systemctl file, filestore, DB name, DB user).

We will migrate the Odoo 11 instance named odoo11-live to a development server, where the name will be odoo11-dev. You should change the version number depending on the Odoo version that you're migrating. 


Backup Your Odoo Instance

The steps in this section should be executed on the production server (where an active Odoo instance is running) as the root user. 


Stop Odoo:

[email protected]:~# service odoo11-live stop


Ensure Odoo is not running

[email protected]:~# ps awxf | grep odo

4458 pts/1 S+ 0:00 \_ grep --color=auto odo 


Backup the Database

Confirm the name of the database to backup:

[email protected]:~# grep db_name /etc/odoo11-live.conf
db_name = odoo11-live


Now, check if the database exists in PostgreSQL.

Switch to the user postgresql and enter PostgreSQL shell:

[email protected]:~# su - postgres

[email protected]:~$ psql
psql (9.5.12)
Type "help" for help.


List all the databases and confirm that the odoo11-live database exists in the Name column:

postgres=# \l

                                    List of databases
    Name     |    Owner    | Encoding |   Collate   |    Ctype    |   Access privileges
 acuto       | acuto       | UTF8     | en_US.UTF-8 | en_US.UTF-8 | acuto=CTc/acuto
 odoo11-live | odoo11-live | UTF8     | en_US.UTF-8 | en_US.UTF-8 |
 odoo11live  | postgres    | UTF8     | en_US.UTF-8 | en_US.UTF-8 | =Tc/postgres         +
             ||||| postgres=CTc/postgres+
             ||||| odoo11=CTc/postgres
 postgres    | postgres    | UTF8     | en_US.UTF-8 | en_US.UTF-8 |
 template0   | postgres    | UTF8     | en_US.UTF-8 | en_US.UTF-8 | =c/postgres          +
             ||||| postgres=CTc/postgres
 template1   | postgres    | UTF8     | en_US.UTF-8 | en_US.UTF-8 | =c/postgres          +
             ||||| postgres=CTc/postgres
(7 rows)


Leave the PostgreSQL shell:

postgres=# \q


Backup the database into a file and logout from the postgresql user.

[email protected]:~$ pg_dump -O odoo11-live | gzip > 20201010-odoo11-live.sql.gz

[email protected]:~$ logout

Note:  The -O (or --no-owner) parameter will make sure that there is no owner on the dumped database.

Note: put the today's timestamp at the beginning of a filename.


Move the database backup file to /root

[email protected]:~# mv /var/lib/postgresql/20201010-odoo11-live.sql.gz .

Note: change postgresql to pgsql if you encounter an error.


Backup the Odoo Application

Go to the /opt directory and create an archive from the Odoo application directory (odoo11-live)

[email protected]:~# cd /opt

[email protected]:/opt# tar czf /root/20180430-odoo11-live.tar.gz odoo11-live


Check if Odoo Instance Has a Virtual Environment for Python

[email protected]:~# cat /etc/systemd/system/odoo-live.service | grep Exec

ExecStart=/opt/odoo11-live/odoo11-venv/bin/python3 /opt/odoo11-live/server/odoo-bin -co /etc/odoo11-live.conf

The first path after ExecStart is the Python executable path. If there is venv in the path, then Odoo is using a virtual environment and you don't need to do anything. 

If an Odoo Instance doesn't have a virtual environment, the path will look similar to this: /usr/bin/python3. If that's the case, proceed to the next step. Otherwise ignore it.


Get a List of Installed Python Packages

This step is only necessary if your Odoo Instance does not have its own virtual environment for Python. 

Save a list of installed python packages on the system into a requirements.txt file and put it in the /root directory.

[email protected]:~# pip3 freeze > /root/requirements.txt


Start Odoo Again

[email protected]:~# service odoo11-live start


Migrating the Odoo Instance

The steps from this section should be executed on the development server (where a development Odoo instance should be running) as the root user. 

NOTE: The development instance is consistently named. For example, Odoo 11 instance will be named odoo11-dev (linux user, /opt directory, configuration file, systemctl file, filestore, DB name, DB user, Apache).


Get the Odoo Backups from the Production Server

[email protected]:~# cd /opt

[email protected]:/opt# scp [email protected]:20201010* .


Note: change host to the hostname (or IP address) of your production server. Change 20201010 to your actual timestamp.


Copy the config file and rename it to odoo11-dev.conf

[email protected]:/opt# scp [email protected]:/etc/odoo11-live.conf /etc/odoo11-dev.conf


Extract the Odoo Application Directory & Rename It

[email protected]:/opt# tar xf 20201010-odoo11-live.tar.gz

[email protected]:/opt# mv odoo11-live odoo11-dev

Note: change 20201010 to your actual timestamp.


Rename the Odoo filestore

The Odoo filestore must match the name of the Odoo database.

[email protected]:/opt# cd odoo11-dev/.local/share/Odoo/filestore/

[email protected]:/opt/odoo11-dev/.local/share/Odoo/filestore# mv odoo11-live odoo11-dev

[email protected]:/opt/odoo11-dev/.local/share/Odoo/filestore# cd /opt


Create the Log Directory

[email protected]:/opt# mkdir /var/log/odoo11-dev


Create a Linux User for Odoo

Create a linux user named odoo11-dev and make it the owner of the application directory and the log file.

[email protected]:/opt# adduser odoo11-dev --home /opt/odoo11-dev

[email protected]:/opt# chown -R odoo11-dev:odoo11-dev odoo11-dev

[email protected]:/opt# chown odoo11-dev:odoo11-dev /var/log/odoo11-dev


Install PostgreSQL

[email protected]:/opt# apt update

[email protected]:/opt# apt upgrade

[email protected]:/opt# apt install postgresql -y


Create the database user odoo11-dev and the database odoo11-dev.

[email protected]:/opt# su - postgres

[email protected]:~$ createuser -d odoo11-dev

[email protected]:~$ logout

[email protected]:/opt# su - odoo11-dev

[email protected]:~$ createdb odoo11-dev


Import the production Odoo database into the odoo11-dev database

[email protected]:~$ gunzip -c /opt/20201010-odoo11-live.sql.gz | psql odoo11-dev 

[email protected]:~$ logout 


Install System Packages

[email protected]:/opt# sudo apt-get install python3 python3-pip python3-suds wget git bzr gdebi-core libxml2-dev libxslt1-dev zlib1g-dev libsasl2-dev libldap2-dev libssl-dev -y


Install additional node packages:

[email protected]:/opt# sudo apt-get install node-clean-css node-less git -y
Install Python 3.6

The default Python version will not work with Odoo 13. We need to install the 3.6 version, along with all the needed tools.


Add a remote repository with Python 3.6

[email protected]:/opt#  sudo add-apt-repository ppa:deadsnakes/ppa

Install Python 3.6

[email protected]:/opt# sudo apt install python3.6 python3.6-dev python3.6-venv


If your production Odoo instance did not have a virtual environment, proceed to the next step. Otherwise ignore it.


Create a Virtual Environment and Install Python Packages

Create a virtual environment in the odoo11-dev directory.

[email protected]:/opt# cd /opt/odoo11-dev && python3 -m venv odoo11-venv


Activate the virtual environment:

[email protected]:/opt# source odoo13-venv/bin/activate


Copy the requirements.txt file from the production server.

(odoo11-venv) [email protected]:/opt# scp [email protected]:requirements.txt .


The library and module details are stored in the requirements.txt file. Use it to install all of the modules at once:

(odoo11-venv) [email protected]:/opt# pip3 install -r requirements.txt


Deactivate the virtual environment:

(odoo11-venv) [email protected]:/opt# deactivate
Install wkhtmltopdf

Download the package

[email protected]:/opt# sudo wget


Additional packages are required for Wkhtmltopdf to run. Install them with the following commands:

[email protected]:/opt# sudo apt-get install libjpeg-turbo8 libjpeg-turbo8 libxrender1 xfonts-75dpi xfonts-base -y
[email protected]:/opt# sudo apt-get install fontconfig

Note: there may be an error during this step. It's normal. The next command will fix it.

[email protected]:/opt# sudo apt-get install -f


Install the package:

[email protected]:/opt# sudo dpkg -i wkhtmltox_0.12.5-1.bionic_amd64.deb


Edit the Configuration File

Change all instances of the odoo11-live string to odoo11-dev in the configuration file.

[email protected]:/opt# cat /etc/odoo11-dev.conf | sed 's/odoo11-live/odoo11-dev/g' > /etc/odoo11-dev.conf


The configuration file will look similar to this:

admin_passwd = snip
db_host = localhost
db_port = 5432
db_user = odoo11-dev
db_password = odoo
db_name = odoo11-dev
addons_path = /opt/odoo11-dev/server/addons,/opt/odoo11-dev/custom_addons
logfile = /var/log/odoo11-dev/odoo11-dev.log
xmlrpc_port = 8089
data_dir = /opt/odoo11-dev/.local/share/Odoo/

Note: make sure that the db_user, db_name, logfile, data_dir, and addons_path correspond to the correct names and paths (especially addons!)


Create a Systemctl Service File

Copy the systemctl service file from the production server: 

[email protected]:~# scp [email protected]:/etc/systemd/system/odoo11-live.service .


Change all instances of the odoo11-live string to odoo11-dev in the systemd service file, then put the file in the correct directory.

[email protected]:~# cat odoo11-live.service | sed 's/odoo11-live/odoo11-dev/g' > odoo11-dev.service

[email protected]:~# mv odoo11-dev.service /etc/systemd/system/


The file should look like this: 


ExecStart=/opt/odoo11-dev/odoo11-venv/bin/python3 /opt/odoo11-dev/server/odoo-bin -c /etc/odoo11-dev.conf


Note: make sure that the User, Group are set to odoo11-dev

Note: Make sure that ExecStart has the correct parameters (python path, Odoo executable, and config)

Execute Odoo and Monitor the Log

[email protected]:~# su - odoo11-dev

[email protected]:~$ /opt/odoo11-dev/odoo11-venv/bin/python3 /opt/odoo11-dev/server/odoo-bin -c /etc/odoo11-dev.conf


If all is well, stop the process and logout from the odoo11-dev user.

[email protected]:~$ logout


Start Odoo With Systemctl

[email protected]:~# systemctl daemon-reload

[email protected]:~# service odoo11-dev start

[email protected]:~# service odoo11-dev status

* odoo11-dev.service - odoo11-dev
   Loaded: loaded (/etc/systemd/system/odoo11-dev.service; disabled; vendor preset: enabled)
   Active: active (running) since Mon 2018-04-30 10:36:49 UTC; 3s ago


If all is well, enable the Odoo service so that it starts at system boot:

[email protected]:/etc/systemd/system# systemctl enable odoo11-dev.service

Created symlink from /etc/systemd/system/ to /lib/systemd/system/odoo11-dev.service.


Install Apache

[email protected]:~# apt install apache2 -y

[email protected]:~# a2enmod proxy_http

[email protected]:~# a2enmod ssl

[email protected]:~# a2enmod rewrite


Enable proxy-http and ssl

[email protected]:~# a2enmod proxy_http

[email protected]:~# a2enmod ssl

[email protected]:~# a2enmod rewrite


Prepare LetsEncrypt for SSL

[email protected]:~# apt install software-properties-common -y

[email protected]:~# add-apt-repository ppa:certbot/certbot

[email protected]:~# apt update

[email protected]:~# apt install python-certbot-apache -y

[email protected]:~# certbot --apache certonly

Note: Provide customer's email address - domain owner


Apache Virtual Host Configuration

Create the site in /etc/apache2/sites-available/odoo11-dev.conf

[email protected]:~# nano /etc/apache2/sites-available/odoo11-dev.conf


Paste the following configuration into the file.

Note that the configuration was created for Search and replace all instances of with whatever hostname is being used for the migrated Odoo instance.

<VirtualHost *:80>
        DocumentRoot /var/www/html

        RewriteEngine on
        RewriteCond %{SERVER_NAME}
        RewriteRule ^ https://%{SERVER_NAME}%{REQUEST_URI} [END,NE,R=permanent]

        ErrorLog ${APACHE_LOG_DIR}/
        LogLevel warn
        CustomLog ${APACHE_LOG_DIR}/ combined

<IfModule mod_ssl.c>
<VirtualHost *:443>
        DocumentRoot /var/www/html

        ProxyPass /        http://localhost:8089/ retry=0
        ProxyPassReverse / http://localhost:8089/ retry=0

        SSLCertificateFile /etc/letsencrypt/live/
        SSLCertificateKeyFile /etc/letsencrypt/live/
        Include /etc/letsencrypt/options-ssl-apache.conf

        ErrorLog ${APACHE_LOG_DIR}/
        LogLevel warn
        CustomLog ${APACHE_LOG_DIR}/ combined


Enable the Configuration File and Reload Apache

[email protected]:/etc/apache2/sites-available# ln -s /etc/apache2/sites-available/odoo11-dev.conf /etc/apache2/sites-enabled/

[email protected]:/etc/apache2/sites-available# service apache2 reload

Was this answer helpful?

« Back

Enterprise-Grade Hardware

  • Samsung
  • Juniper
  • Western Digital
  • Supermicro
  • LSI
  • Intel
  • R1Soft Backups
  • cPanel
  • MySQL
  • Parallels
  • HP Partner