Odoo Help

Welcome!

This community 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.

2

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

By
Stijn Staelens
on 9/22/14, 4:50 AM 4,459 views

Hello,

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?

 

0
Qamar Soft
On 9/22/14, 5:20 AM

backup

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

Restore

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

Qamar Soft
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

Your Answer

Please try to give a substantial answer. If you wanted to comment on the question or answer, just use the commenting tool. Please remember that you can always revise your answers - no need to answer the same question twice. Also, please don't forget to vote - it really helps to select the best questions and answers!

About This Community

This community is for professionals and enthusiasts of our products and services. Read Guidelines

Question tools

2 follower(s)

Stats

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