Přejít na obsah
Menu
You need to be registered to interact with the community.
This question has been flagged
1 Odpovědět
13796 Zobrazení

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?

 

Avatar
Zrušit
Nejlepší odpověď

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

Avatar
Zrušit
Autor

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?

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

Autor

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.

Related Posts Odpovědi Zobrazení Aktivita
2
srp 18
19319
0
bře 15
4811
0
bře 25
1176
0
led 25
3220
1
srp 23
14496