How-to restore an Odoo backup (quick help)


If you need this how-to, your best option is to use the Lynx web browser in a terminal session on the server. It is text-mode only. Obviously, you will first copy the backup on the server file-system.

Terminal based

Often, you don’t need to restore images or attachments. They are recorded in the  server filesystem. In this case, you can remove the filestore/ part from the backup file and use the one already on your server (see below). It is the heavier part of the backup. Assuming the database name is www and the owner is odoo, proceed as below (this way you can reuse your filestore/ folder) :

$ sudo su postgres
$ dropdb www
$ createdb -O odoo www
$ psql www < dump.sql

Restoring database from web browser

First, increase http server time-out, don’t forget to restart the daemon.

Following nginx documentation, you can set client_max_body_size to 25M ( or any value you need ) in the following context : http, server, location. So just set it wherever you want. For example :

# increase size to 300 MB for restoring backups
client_max_body_size 300M;

Launch the database manager https://[odoo_url]/web/database/manager and follow the instructions to upload your backup file.

Restoring database from Terminal

Understanding the backup file

The Odoo 10 backup utility does a classical Postgresql dump and agregate metadatas and static files. Unzip the backup file, you will get :

  • filestore/
    static files stored on disk, like images, attachments, …
  • dump.sql
    Postgresql backup — your datas
  • manifest.json
    contains list of modules, Odoo version, db name, Postgresql version, etc.

As a direct result of Postgresgl command, the dump.sql part can be restored with a simple Postgresql command, and the filestore/ part copied to the server (usually in /var/lib/odoo).

Replacing the current database

In case you want to restore with the same database name, you will first delete your database before recreate it. This way you can reuse your filestore/ folder :

$ dropdb database_name

Restoring dump file

Before restoring you have to create a new database (you need to create the database using the same Postgresql user of Odoo or you won’t be able to use it) :

$ createdb new_database_name

Or pass the Postgresql user name :

$ createdb -O db_user_name new_database_name

Unzip the backup, filestore/ files goes to:


and dump.sql will be restored with :

$ psql new_database_name < dump.sql

One can’t use the pg_restore utility because Odoo creates sql backup in text format instead of archive format.
If you created you own backup using pg_dump utility, it is in archive format. In this case only use pg_restore like this (the -C option will force Postgresql to use the database name stored in the dump file) :

$ pg_restore -d any_database_name -U root -C dump.sql

NB : use below command to restore large backup file

What is the default modules folder in Odoo ?

I host my Odoo servers on Centos 7 and Debian Linux. This short answer is also right for any Linux distribution using packages downloaded from Odoo website either RPM (Red-Hat, SuSE, Mageia, …) or DEB (Ubuntu, Linux Mint, …).

Odoo RPM and DEB packages comes with 2 default modules folder :

  1. Python packages folder which is default addons folder in odoo.conf. It is used only by packages (rpm, deb and Python packages). It is reserved for Odoo default modules, do not use it. Rpm and Deb use quite the same folder :
    • For RPM (Centos 7) it is /usr/lib/python2.7/site-packages/odoo/addons
    • For DEB (Debian 9) it is /usr/lib/python2.7/dist-packages/odoo/addons
  2. Customized addons folder which is not writed in odoo.conf as it is allways read. It is a good location for your downloaded modules.
    • For RPM (Centos 7) it is /var/lib/odoo/addons/[Odoo #version]
    • For DEB (Debian 9) it is /var/lib/odoo/.local/share/Odoo/addons/[Odoo #version]

You can allways add several modules folder at you prefered locations, as long as you add those locations path in /etc/odoo/odoo.conf

Install packaged Odoo on Debian / Ubuntu / Linux Mint without python-pypdf dependency

This is a fast and easy way to install Odoo 10 official package on Debian 9 or Ubuntu 16.04 LTS server. Just create a fake python-pypdf 1.13 deb package.

Odoo 10 deb package depends on the old Python PyPdf unmaintained package. This is only a dependency problem against Python-PyPdf package. That package is no more available in several distributions, notably Debian 9 (stretch) and Ubuntu since 16.04 LTS. It is replaced by the new PyPDF2 package which claims to be fully compatible, but does not provide PyPdf  as a virtual package. The problem is the same if you want to install  Odoo 8 and Odoo 9 on recent Debian based distros.

However, there is an easy workaround : create a fake python-pdf package and install python-pyPdf from Pipy (Python repository). All of this will be done as root. There is no need to use the source Github version.

Tutorial :

  • install equivs to create fake packages and python-pip to install pypdf package from Python repository ;
  • run equivs-control python-pypdf, this will create and populate the file python-pypdf ;
  • edit the file (dot and space under Description are mandatory) like below :
    Section: python
     Package: python-pypdf
     Version: 1.13
     Description: fake package to provide python-pypdf
     This package provide the dependency needed by Odoo. 
     python-pypdf2 replace python-pypdf, but while compatible, 
     does not provide python-pypdf
     python-pypdf will need to be installed with 
     "pip install pyPdf"
  • run equivs-build python-pypdf, this will create the fake package python-pypdf_1.13_all.deb ;
  • install the package with dpkg -i python-pypdf_1.13_all.deb ;
  • run pip install pyPdf ;
  • install Odoo 10 (or install the 100% free Odoo 8) on your Debian/Ubuntu box.

Your feedback will be appreciated.

P2V tools – Physical to virtual system conversion

How to virtualize a physical computer ?

While you can find a lot of web pages and blogs asserting that you need to change some esoteric things (Windows registry and so on) in the running system before running it virtualized, fact is that it is not true :

You just need to clone the harddrive(s) in a file. End of story.

Basic disk utilities can do that (under Linux, BSD and MacOSX one can use dd), many backup tools too. Later on, you will convert the file to the desired virtualization format, which is trivial to do (tools depends on your virtual hypervisor engine).

Things are a bit more complicated if your system use several disks or partitions. But once again you just need to clone them. Several small utilities can do that for you, directly converting disks images in one file only. Under Windows, Microsoft provide the small and freely available Disk2vhd (go to the Windows Sysinternals page and download the utility) or you may prefer an automated tool like the free AOMEI Backupper. Again, many free tools exists, P2V is trivial.

How to do an Odoo inventory import

In Odoo, inventories are managed through Inventory / Inventory Control / Inventory Adjustments. Importing your stock, means creating an inventory adjustment. You will import your first stock (initial inventory), using exactly the same procedure as later stock’s imports.

Minimal prerequisites

  • At least one warehouse created (should be done automaticaly)
  • Products and variants already imported

First obvious option is to create a new Inventory Adjustment, checking the « All products » option. Then press Start Inventory button : products will be populated. You can modify stock inline in Real Quantity column. But with lots of products, you will prefer to do that in a spreadsheet :

  1. keep your first Inventory Adjustment in draft mode,
  2. go back to Inventory Adjustments, select your inventory, export it (select the required fields as the below list),
  3. update your spreadsheet and import it back.

Required fields to export / import

  • Company (company id) : company_id/id, usually « base.main_company »
    (this field should have only one record)
  • Inventoried Location (warehouse) : location_id/id, with only one warehouse it will be « stock.stock_location_stock »
    (this field should have only one record)
  • Inventory Reference (inventory name) : name, whatever
    (this field should have only one record)
  • Inventories / Product (product external id) : line_ids/product_id/id
  • Inventories / Product Name : line_ids/product_name
  • Inventories /Checked Quantity (product stock) : line_ids/product_qty

You will get also (automaticaly added) :

  • Stock inventory id (external id) : id
  • Inventories : line_ids/location_id/id

Step by step how-to import products stock in Odoo

Open a spreadsheet, populate it with your product names, product external id and product quantity — much easier to export them from Odoo ; export from product’s variants if you use them.

Rename your columns as follow :

  • Product name : line_ids/product_name
  • Product external id : line_ids/product_id/id
  • Product quantity : line_ids/product_qty

Add following columns (corresponding to field’s name) at the end. The order doesn’t matter :

  • company_id/id
    (this column will contain one record on the first line only, usually « base.main_company »)
  • location_id/id
    (this column will contain one record on the first line only, usually « stock.stock_location_stock »)
  • name
    (this column will contain one record on the first line only, put whatever you want)
  • line_ids/location_id/id
    (every line will contain the same value as the first line of location_id/id)

Save it as a CSV file. Open Odoo Inventory menu, go to Inventory Adjustment and press the Import button.

Once imported, a new entry will be created in Draft status. Open the entry and press Start Inventory. Validate the inventory if everything is ok.


How to export an aging inventory with Odoo

Odoo apps are well integrated. Products datas are shared accros modules, and the accounting module can « talk » very well with the inventory one. Doing everything in Odoo is easy. But sometimes you need just a spreadsheet with your past inventory at a precise date. That functionality is a bit hidden. Here’s how to enable it :

  1. install the Accounting module
  2. enable multi-location inventory
  3. switch to developper mode to see hidden menus
  4. go to Inventory / Reports / Aging inventory

To export :

Quickly done

… but product name, stock and stock value only

  1. on the right of the list view, click on Tableau Croisé dynamique
  2. now click on the download icon (xls file)

Complete nightmare

… but you may be able to export every needed field

  1. from list view unfold all products, check the checkbox
  2. click on Action / Export
  3. click on all available fields
  4. choose your fields, don’t forget inventory moves, quants and associated dates
  5. export
  6. try to play with your spreadsheet
  7. go to Quickly done

Odoo installation on a minimal Centos 7.x / RedHat 7.x web server

This how-to describe a minimal Odoo installation on Centos or RedHat. It can be easily adapted to any Linux distribution (Debian, Ubuntu, SuSE, Mandriva, Arch Linux, …). This a simple, easy and rock-solid way to install Odoo for small groups.

An eye on the doc

First steps — just for those who forget something

Create one user account, add the user to the wheel group. This will let you use sudo. Add your ssh-key, from local to remote :

$ ssh-copy-id -i ~/.ssh/ user@IP

Install Yum utilities and some of your favorite’s command-line tools. Yum utilities comes with the useful yum-config-manager. Even if you don’t use it, it can show you the whole params of each repositories. Here below I install  Lynx text browser to read html pages in Midnight-Commander.

# yum install yum-utils
# yum install nano mlocate screen wget mc lynx unzip

Install postgresql-server and start it, otherwise Odoo will not be able to create odoo user.

# yum install postgresql-server
# postgresql-setup initdb
$ systemctl start postgresql

Enable EPEL repository

We need complementary packages, not provided by distribution repository. Basicaly we have two solutions :

  1. add Software Collections packages
  2. add new repositories

Software Collections are installed in parallel from distribution’s package. Our server will only run Odoo, so there is no need to separate packages. It is easier to add repositories.

EPEL is Extra Packages for Enterprise Linux. The epel-release package is included in the CentOS Extras repository that is enabled by default. One just need to type :

# yum install epel-release

To clear any cached information, and to make sure the changes are immediately recognized :

# yum clean all 
# yum update

If you need, install some more utilities from Epel. I like p7zip.

Add Odoo repository

Odoo provide package. You can download it or install from nightly builds repository (both are the same).

# yum-config-manager --add-repo=
# yum clean all
# yum update
# yum install odoo
$ systemctl start odoo

Download wkhtmltopdf and install it. Do not use the package from Epel repository as it can’t handle headers and footers.

A bit of testing

Stop Firewalld and connect to http://[your-hostname]:8069/ default login/password is admin/admin. Create a dummy or template database. Don’t install applications, just configure Administrator account :
in configuration menu, go to users and change Administrator’s timezone, email, and choose a solid password. You will be disconnected. Login with the new params. If it’s ok, disconnect again and stop Odoo server. Restart Firewalld to protect your web server.

Basical configuration

Odoo master password, Firewalld, fail2ban, services.

Choose a new Odoo master password. You may play with a password generator. Add it to odoo.conf :

# nano /etc/odoo/odoo.conf

; This is the password that allows database operations:
admin_passwd = whatever big and solid
db_host = False
db_port = False
db_user = odoo
db_password = False
addons_path = /usr/lib/python2.7/site-packages/odoo/addons

Need to open the port on Firewalld. We create Odoo service that we will enable on the firewall public zone.

# nano /etc/firewalld/services/odoo.xml

<?xml version="1.0" encoding="utf-8"?>
  Open Odoo default port.
 <port protocol="tcp" port="8069"/>

Enable Odoo on public zone ; the –permanent option needs to be the first option for all permanent calls (1). Don’t forget to reload the firewall !

# firewall-cmd --permanent --zone=public --add-service=odoo 
# firewall-cmd --reload

Similarly, enable http and https services:

# firewall-cmd --permanent --zone=public --add-service=http
# firewall-cmd --permanent --zone=public --add-service=https
# firewall-cmd --reload

Install and start Fail2ban, then enable services on startup :

# systemctl enable postgresql
# systemctl enable odoo
# systemctl enable fail2ban

And start Odoo again. Connect to Odoo.

A template database

Now we will setup a « template » database. Something with all the basics that we need. Start with security and backup :

Install Letsencrypt and Database Auto-Backup module from OCA’s server tools repository. Download zip from

Setup auto-backup. Test it : make a backup, get it, try to restore.

You will certainly need to increase the time-out on your server. Beware that as long as you db grows, the backup grows as well. But the heavier part will certainly be the multiples files (images, documents, …) that Odoo will generates for you.

Use Letsencrypt to get an SSL certificate as soon as domains are moved on your server.

Web environment ribbon is a very useful utility for those who works on several Odoo instances. You will got a red ribbon on the top left corner in every page (ribbon name and color can be changed).

Add users, configure company, email servers, etc.

Backup or duplicate your database with Odoo database manager. You will leave your first copy untouched. It will be used as a template. For further installations, just duplicate your template and install everything you need.

If you want a server admin panel

Avoid extra dependencies (PHP, MySQL, …). If you can, choose Perl based or Python based software, because Perl and Python language are already installed on your server.

  • Webmin use Perl, it have a lots of modules, is actively developped, but old ;
  • BlueOnyx is built with Java and Perl, based on a product developped by Cobalt, it’s solid but a bit old ;
  • Ajenti use Python but does only a few things so far, it is recent and light ;
  • A few other ones doesn’t need MySQL, but use PHP.

Accelerate Odoo

Depending on what you need you will configure Postgresql, Odoo and Nginx web server for speed and efficiency.

How-to move Odoo to another server

On the old server Odoo is setup with e-commerce website. On the new server, avoid extra dependencies if Odoo doesn’t need them (web server, php, …).

First steps

  1. keep a TODO-list
  2. create a subdomain, to test your payment module on the new server
  3. install your ssh-key
  4. install some command-line tools : midnight-commander, nano editor, mlocate, wget, screen, unzip
  5. might want to install a graphical web-server admin. I like Webmin, because it’s well maintained, depends only of Perl and use its own web server.
  6. install a networked resource monitoring tool with graphs output, like Munin (or webminstats if you use Webmin)
  7. install Postgresql, create necessary users and configure it. Refer to Odoo install documentation.
  8. install Odoo, setup Odoo with workers and debug log
  9. stop firewall to access Webmin and Odoo, you will configure the firewall later (TODO list)

Setup Odoo

  1. create a dummy database with all necessary modules, add all modules you had on the old server. Test it (might want to include demo datas to test it extensively — check ‘evaluate Odoo’ when you are creating the database).
  2. test your credit card payment module
  3. backup your old Odoo database
  4. create a new, empty, database on the new server
  5. restore your old database on the new database. test it extensively
  6. install letsencrypt Odoo module, first install python-pip, then do
    sudo pip install acme-tiny
    sudo pip install IPy
  7. install auto backup odoo module on the new server and test it : do a backup/restore operation. First install python-pip and do
    sudo pip install pysftp
  8. install nginx and set it up
  9. install fail2ban
  10. open necessary ports on the firewall and restart it