恢复Postgres数据库转储

时间:2016-02-09 10:42:02

标签: postgresql

无法恢复Postgres数据库转储

我使用了以下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

我收到了上面的错误日志(我有几行这样的日志,我用了几行作为参考)。

执行命令后,数据库仍然包含旧记录,而不是新记录。

1 个答案:

答案 0 :(得分:4)

我删除了现有数据库并创建了新数据库。

$dropdb development_db_name
$ createdb developmnent_db_name

然后我使用

恢复了数据库
 sudo psql my_database_name < feb9.sql