Odoo Help


Odoo v8 Backing up and restoring a database from commandline. How to achieve this?

Stijn Staelens
on 9/22/14, 4:50 AM 7,525 views


I'm trying to automate the backup of the database. I created a backup with the following command:

pg_dump --format=c --no-owner --username=postgres <dbname> > backup.dump

This seems to work as advertised. A dump is created.

To test this backup, I dropped the database from the database manager webpage. Then in commandline I use:

createdb -T template0 <name> 

pg_restore --no-owner --dbname=<name> backup.dump

A database is created and the restore happened. But when I go to the database manager webpage, no database is found.

If I try restoring with the restore webpage, I get an error saying "Could not restore the database"

Any ideas on how to fix this?


On 9/22/14, 5:20 AM


pg_dump --host "hostsIP"  --port 5432 --username "userName" --no-password  --format custom --blobs --verbose --file "PATH/TO/FILE.dump" "dbName"


pg_restore --host "hostIP" --port 5432 --username "userName" --dbname "dbName" --no-password  --verbose backup.dump

I created a dump the way you said. Restoring with the webpage still gives me an error. If I refresh the page afterwards I see the new database. I can choose it to login with, but the data hasn't been restored. (users don't exist, password of admin user is the default one,...). Restoring by commandline (pg_restore you provided) restores the db, but I cannot see it in the database manager. Any idea what I am doing wrong?

Stijn Staelens
on 9/22/14, 6:16 AM

reboot your postgresql server that error came when the database is in use from another pid

on 9/22/14, 7:05 AM

I found it, The owner of the database I created with the commandline was wrong. I altered the database to set the correct user and now it works. Thank you.

Stijn Staelens
on 9/22/14, 7:21 AM

About This Community

This platform is for beginners and experts willing to share their Odoo knowledge. It's not a forum to discuss ideas, but a knowledge base of questions and their answers.


Odoo Training Center

Access to our E-learning platform and experience all Odoo Apps through learning videos, exercises and Quizz.

Test it now

Question tools

2 follower(s)


Asked: 9/22/14, 4:50 AM
Seen: 7525 times
Last updated: 3/16/15, 8:10 AM