How-to restore an Odoo backup (quick help)

Emergency

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.

In case you don’t need it, you can remove the filestore/ part from the backup file and use the one already on your server. It is the heavier part of the backup (see below).

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 Po

stgresgl 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).

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

Unzip the backup, filestore/ files goes to:

/var/lib/odoo/filestore/[new_database_name]]

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