Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Restore Postgres database dump

Tags:

postgresql

Unable to restore Postgres db dump

I have used following commnands

 sudo psql my_database_name < feb9.sql
    SET
    SET
    SET
    SET
    SET
    CREATE EXTENSION
    COMMENT
    SET
    SET
    SET
    ERROR:  relation "admin_tools_dashboard_preferences" already exists
    ALTER TABLE
    ERROR:  relation "admin_tools_dashboard_preferences_id_seq" already exists
    ALTER TABLE
    ALTER SEQUENCE
    ERROR:  relation "admin_tools_menu_bookmark" already exists
    ALTER TABLE
    ERROR:  relation "admin_tools_menu_bookmark_id_seq" already exists
    ALTER TABLE
    ALTER SEQUENCE
    ERROR:  relation "auth_group" already exists
    ALTER TABLE
    ERROR:  relation "auth_group_id_seq" already exists



ERROR:  duplicate key value violates unique constraint "product_rateclass_code_uniq"
DETAIL:  Key (code)=(0) already exists.
CONTEXT:  COPY product_rateclass, line 1: "40787    0   Tariff Rates"
 setval 
--------
  40791
(1 row)
ERROR:  relation "admin_tools_menu_bookmark_user_id" already exists
ERROR:  relation "auth_group_name_like" already exists
ERROR:  relation "auth_group_permissions_group_id" already exists
ERROR:  relation "auth_group_permissions_permission_id" already exists
ERROR:  relation "auth_permission_content_type_id" already exists
ERROR:  relation "auth_user_groups_group_id" already exists
ERROR:  relation "auth_user_groups_user_id" already exists
ERROR:  relation "auth_user_user_permissions_permission_id" already exists
ERROR:  relation "auth_user_user_permissions_user_id" already exists
ERROR:  relation "auth_user_username_like" already exists
REVOKE
REVOKE
GRANT
GRANT

I have received the above error logs (I have such logs running into hundreds of lines, I have used several lines for reference).

Post execution of the command, the database is still containing old records, instead of new records.

like image 362
onkar Avatar asked Feb 07 '23 19:02

onkar


1 Answers

I dropped the existing database and created the new one.

$dropdb development_db_name
$ createdb developmnent_db_name

Then I restored the db using

 sudo psql my_database_name < feb9.sql
like image 162
onkar Avatar answered Feb 16 '23 10:02

onkar