How to restore a Database Backup?

How to restore a Database Backup locally?

Abstract

What should be considered when restoring a database for local development?


Restoring a Database locally

You can either use the Odoo's Database Manager or doing it via SQL

What's the difference on using one or the other?

​Odoo Database Manager

​If you choose this option, you'll be able to add the filestore included on the backup, meaning that you'll use the zip file you received. Sometimes, you could face errors when restoring the database using this way and that's when you have to use psql to restore



​Restore using PSQL

​This method is more efficient but if you need the filestore, then you don't have to use this one. This is useful when you have errors trying to restore the zip or sql file using the Odoo's option.

On your terminal run the following commands:

  1. psql
  2. createdb <db_name> (make sure to not repeat the name of an existing database)
  3. <psql <db_name> < /path/to/dump.sql


Changing the admin credentials to access to the restored DB

​After restoring the Anon DB then we need to change the admin credetials in order to access with the admin user.

On your terminal run the following commands:

  1.  psql
  2. \c <db_name>
  3.  update res_users set password='admin' where login='admin';
    1. Note: sometimes the admin user's login is not admin. On that case you can either target the id of the admin (request it to the tech lead or consultant) and do:
		​update res_users set password='admin', login='admin' where id=X;


Then you are all set to start using the anon db


Useful commands

​Re-Activate expired Database

If your database is expired you can run this commands to extend its lifetime: 

  1.  psql
  2. \c <db_name>
  3.  UPDATE public.ir_config_parameter 
    SET value = '2025-05-15 00:00:00' WHERE key = 'database.expiration_date';
    UPDATE ir_config_parameter
    SET value = 'renewal' WHERE key = 'database.expiration_reason';