How to duplicate a production DB and use it to test - coopdevs/handbook GitHub Wiki
:warning: ATENCIÓ |
---|
Aquest handbook està descontinuat. La nova adreça és: https://handbook.coopdevs.org/ca/home |
How to duplicate a production DB and use it to test
Some time you need to test something on a DB with production data. Generally, our setup already creates two DBs, one for production and one for test. With this guide you'll be able to duplicate the production DB and use it for test purposes.
Keep in mind that with our setup you have two different sub-domains, one for each DB (e.g. odoo
and odoo-test
).
Prerequisites
In order to execute the following steps, you'll need:
- production DB master password
It should be stored in Bitwarden. If it's not there... please ask a sysadmin to add it.
Steps
- Go to the production subdomain and visit the Database Manager (e.g.
https://odoo.mydomain.coop/web/database/manager
) - Download a backup of the production DB
- Go to the test subdomain and visit the Database Manager (e.g.
https://odoo-test.mydomain.coop/web/database/manager
) - Make sure you're in the test subdomain and NOT in the production subdomain...
- Delete the existing DB
- You'll get an "Internal Server Error", don't worry... it's normal. That Odoo process doesn't have a DB to run with anymore.
- Visit the test Database Manager (e.g.
https://odoo-test.mydomain.coop/web/database/manager
) - At the end of the form, choose to restore a database
- Fill in the test DB master password, browse and select the zip file generated by point 2, use the test DB name (e.g.
odoo-test
) and select "This database is a copy" option. Make sure that the DB name you choose is the same as the DB deleted in point 5. - Ask a sysadmin to provision the server, this will place everything in order in the test environment
When adding a test DB implies renaming prod domain
Steps
- Download a backup of the prod DB before doing anything.
https://odoo.mydomain.coop/web/database/manager
- Run provisioning with the new prod and test subdomains.
- The DB's of the new domains will be empty
- Go to the new prod subdomain and visit the Database Manager (e.g.
https://odoo-new-prod.mydomain.coop/web/database/manager
) - Delete the existing DB
- You'll get an "Internal Server Error", don't worry... it's normal. That Odoo process doesn't have a DB to run with anymore.
- Visit the new prod subdomain Database Manager (e.g.
https://odoo-new-prod.mydomain.coop/web/database/manager
) - At the end of the form, choose to restore a database
- Fill in the DB master password, browse and select the zip file with the old prod DB of the first point, use the new prod DB name (e.g.
odoo-new-prod
) and select "This database is a copy" option. Make sure that the DB name you choose is the same as the DB deleted in point 5. - Repeat the previous steps for the new test subdomain and new test DB name using again old prod DB backup of first step.
- Disable cron jobs and ingoing and outgoing mail servers for test DB. (
UPDATE ir_cron SET active='f'
DELETE FROM ir_mail_server
DELETE FROM fetchmail_server
inpsql [*new test DB name**](/coopdevs/handbook/wiki/*new-test-DB-name**)
- Run provisioning again to install unaccent psql extension and enable ribbon in test (ensure that
web_environment_ribbon
Odoo module is in inventory.
Alternative steps if you forget to backup the old prod DB at first
- Edit /etc/odoo/odoo.conf and comment the line with
dbfilter
- Restart Odoo
- Go to
https://odoo.mydomain.coop/web/database/manager
and you will see the new empty DB's and also theold prod DB
. Here you can get the backup to follow the previous steps. - Uncomment the line with
dbfilter
- Restart Odoo
- Continue with previous step 4.