We can restore the Odoo database in several ways. We can easily back up the database and restore the database from the Odoo front end.
To do so, go to the database manager option (<odoo-url>/web/database/manager) and click the backup button.
If you set a master password it will ask the master password first, later select the backup format.
In Odoo, there comes mainly two types of backup format.
1. zip(Include filestore)
2. pg_dump custom format (without filestore)
Upon selecting the first option, it will generate a zip file containing a file store, dump.sql, and manifest.json.
Where, filestore contains all the static files stored on disk such as images, attachments, the dump.sql file mainly contains all the (Postgresql backup) data and the manifest.json file contains the list of modules, Odoo version, database name, Postgresql version and more.
Either you can restore the database from the front end or you can restore the database from the terminal.
To restore the database from the front end, go to the database manager then click the “Restore Database” button.
A popup window will appear.
Then browse the .zip file of the backup of your database and give a new database name. Then you can click the continue button. A new database will be created.
If you don’t want to restore the filestore part(ie the images and attachments), then you can restore the database using the dump.sql file from the terminal. Extract the database backup .zip file, there will be 3 files (Filestore, manifest.json, dump.sql).To restore the database using dump.sql, firstly create a database and then execute the command to restore the database from dump.sql.
Open a terminal from this file location, then enter the following commands to restore the database.
$sudo su postgres
$createdb -O [Owner] [database_name]
$psql [database_name] < dump.sql
In the same way you can restore the .dump backup file .Go to database manager (<odoo-url>/web/database/manager) ,then backup the database in the pg_dump custom format (without filestore) ,you will get a file with extension .dump.
Open the terminal, then enter the following commands to restore the database.
$sudo su postgres
$createdb -O [Owner] [database_name]
$pg_restore -d [database_name] [dumpfile_name].dump
Refer our previous blog on how to access the database and manage the database from our blog Odoo Database Management