How-to-Migrate-Odoo-from-one-Server-to-Another

How to Migrate Odoo from one Server to Another

Spread the love

In this tutorial, we will show you how to completely migrate your Odoo installation, from one server to another. In this tutorial, an Ubuntu 16.04 server is used as both source and destination server. The migration is also possible between different Linux distributions. If this is the case, you can use one of our Linux Host Support Services, and simply ask our expert Linux admins to do the migration for you.

Requirements:

  • SSH access on both, the source and destination server is required
  • Python, PostgreSQL and any additional dependencies like wkhtmltopdf, should already be installed on the destination server before initiating the transfer

 

1. Creating a backup on the source server

First, we will need a backup of your PostgreSQL database on your source server.

Log in via SSH as the odoo user on your server:

su odoo_user

Now, navigate to your Odoo directory:

cd /path/to/odoo

You can list the databases you have stored with the following command:

psql -l

You can export your odoo database by using the pg_dump command:

pg_dump dbname > db_backup.sql

Where “db_name” is the name of the database you need to export and “db_backup.sql” will be the name of the exported database.

Alternatively, if you don’t want to export your database through the command line interface, you can use some web-based GUI administration tools like phpPgAdmin or Adminer.

You can also export your database through your Odoo Database Manager directly from your browser by opening the following URL:

http://your-odoo-domain/web/database/manager

where “your-odoo-domain” is the name of your actual domain or your server IP address.

You also need to copy your odoo init and configuration file to the current directory.  For example:

cp /etc/init.d/odoo-server .
cp /etc/odoo-server.conf .

You can also open the odoo-server.conf file and check for any alternative custom addons location outside the odoo root directory. If there is, you should copy these addons as well to our current directory:

cp /path/to/odoo/addons .

Now, that we have everything we need in one place (make sure again that you are inside your Odoo directory on your server), we can create an archive of all these files with the following command:

tar -czf odoo_backup.tgz *

2. Transfer the backup

Before you transfer the backup we have made, first, you must log to your destination server and create a new user there:

adduser odoo_user

Now you can copy the backup archive from your source server to the destination with the rsync command (execute this command on the source server):

rsync -avz --progress -e "ssh -p 22" odoo_backup.tgz odoo_user@destination-ip-address:/home/odoo-user/

If SSH listens on a different port on the destination server, change the ssh port number accordingly.

You can extract the archive with the following command:

tar -zxf odoo_backup.tgz

You also need to copy your odoo-server.conf  and init file to the appropriate location;

cp odoo-server.conf /etc/
cp odoo-server /etc/init.d/

Depending on where you have placed your odoo directory, you will need to change the path to your addons directory accordingly inside the odoo-server.conf file:

nano /etc/odoo-server.conf

and edit the path for the addons_path if necessary.

Switch back to user root, and create the appropriate log file at the location specified in the configuration file. For example:

touch /var/log/odoo-server.log

3. Restoring the Database

To restore the database, create a new postgresql user with the following commands:

su postgres
createuser odoo_user

Create an empty database by executing:

createdb odoo_db

Give a password to the user:

psql
psql=# alter user odoo_user with encrypted password 'strong-password';

And grant all privileges on the database with:

grant all privileges on database odoo_db to odoo_user ;

Now, you can import your database from the source server into the newly created empty database by executing the following command:

psql odoo_db < /path/to/db_backup.sql

Again, you can use the alternative tools we have mentioned before to do this, or you can directly export it from your browser using the Odoo Database Manager.

You should also assign your odoo_user as the owner of all the files in your current odoo directory:

chown -R odoo_user: /path/to/your/odoo/directory

With this, the migration of your Odoo should be completed.

 

4. Start your Odoo Server

You can now start your Odoo on the new server with the following command:

service odoo-server start

You can also try to open your Odoo inside your browser and test if everything is working properly. Congratulations!

 

If you are one of our Linux Host Support customers, you don’t have to do any of this, simply ask our admins, sit back and relax. Our admins will migrate your Odoo from one server to another for you immediately.

PS. If you liked this post please share it with your friends on the social networks using the buttons on the left or simply leave a reply below. Thanks.

7 thoughts on “How to Migrate Odoo from one Server to Another

  1. Hi, thanks a lot for your help!

    I would like to know if you must include in your backup file the filestore related to this data base.

    Thanks

    1. If you backup the database through the Odoo Database Manager, the filestore is included in the backup file, otherwise you need to backup the filestore manually.

        1. If Odoo is installed in the /opt/odoo directory, then location is /opt/odoo/.local/share/Odoo/filestore

Leave a Reply

Your email address will not be published. Required fields are marked *