To clone database or copy database from existing one in odoo server, we need some smart and easy stuff.

SELECT pg_terminate_backend(pg_stat_activity.pid) FROM pg_stat_activity
WHERE pg_stat_activity.datname = ‘odoo-apps-db‘ AND pid <> pg_backend_pid();

Here first this command helps to disconnect all active session from database to clone.

Now we can clone database.

CREATE DATABASE odoo-apps-db2 WITH TEMPLATE odoo-apps-db OWNER dbuser;

Above command as complete, gives you duplicate copy of database.

Now in odoo, we had domain name inside system parameter, that’s as well need to change.

update ir_config_parameter set value = ‘http://new-host-domain-name.’ where key = ‘web.base.url’;

This make complete right way clone of odoo database with postgresql database system.

Hope !  this helps guidelines may helps you. Have a wonderful day.