简体   繁体   English

如何使用 psql 从 gzip 文件恢复 postgres db? (arelle: XBRL SEC DB)

[英]How to restore postgres db from gzip file using psql? (arelle: XBRL SEC DB)

I downloaded the xbrldb_SEC_pg_2014-11-02.pg.gzip postgres pg_dump file from arelle.org.我从 arelle.org 下载了 xbrldb_SEC_pg_2014-11-02.pg.gzip postgres pg_dump 文件。 I then ran the schema ddl file in pgAdminIII and it recreated all of the databases, functions, etc.然后我在 pgAdminIII 中运行模式 ddl 文件,它重新创建了所有数据库、函数等。

When I try to restore the databases using the following:当我尝试使用以下方法恢复数据库时:

desktop:~/Downloads$ sudo postgres zcat xbrldb_SEC_pg_2014-11-02.pg.gzip | psql -U postgres public

I get:我得到:

sudo: postgres: command not found psql: FATAL: Peer authentication failed for user "postgres"

I can zcat the file into a file to expand it.我可以将文件 zcat 成一个文件以展开它。 Looks like it is a pg_dump file.看起来它是一个 pg_dump 文件。

postgres=> pg_restore -a /home/jeremy/Downloads/xbrldb_SEC_pg_2014-11-02.txt
postgres-> ;
ERROR:  syntax error at or near "pg_restore"
LINE 1: pg_restore -a /home/jeremy/Downloads/xbrldb_SEC_pg_2014-11-0...
    ^
postgres=> pg_restore -a postgres /home/jeremy/Downloads/xbrldb_SEC_pg_2014-11-02.txt;
ERROR:  syntax error at or near "pg_restore"
LINE 1: pg_restore -a postgres /home/jeremy/Downloads/xbrldb_SEC_pg_...

So then I tried to use PG Admin III, and my output:然后我尝试使用 PG Admin III,我的输出:

/usr/bin/pg_restore --host localhost --port 5432 --username "postgres" --dbname "public" --role "postgres" --no-password  --section data --data-only --exit-on-error --table accession --schema public --verbose "/home/jeremy/Downloads/xbrldb_SEC_pg_2014-11-02.backup"
pg_restore: [archiver] input file appears to be a text format dump. Please use psql.

Process returned exit code 1.进程返回退出代码 1。

May I please ask what I need to do to get the databases restored?请问我需要做什么才能恢复数据库?

Does anyone know what I need to do to get the database updated from 2014-11-02 to the current date?有谁知道我需要做什么才能将数据库从 2014-11-02 更新到当前日期?

You should run psql as postgres user, not zcat, so try to use following:您应该以postgres用户而不是 zcat 用户身份运行 psql,因此请尝试使用以下命令:

zcat xbrldb_SEC_pg_2014-11-02.pg.gzip | sudo -u postgres psql public

PS pg_restore is an utility, not a PostgreSQL command, that means you should run it from command line, not from psql. PS pg_restore 是一个实用程序,而不是 PostgreSQL 命令,这意味着您应该从命令行运行它,而不是从 psql。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM