我用
pg_dump db_production > postgres_db.dump
然后使用scp将其复制到localhost。
现在当我导入我的本地db时,它给出了一个错误
pg_restore: [archiver] input file appears to be a text format dump. Please use psql.
使用命令行
pg_restore -d db_development postgres_db.dump
我用
pg_dump db_production > postgres_db.dump
然后使用scp将其复制到localhost。
现在当我导入我的本地db时,它给出了一个错误
pg_restore: [archiver] input file appears to be a text format dump. Please use psql.
使用命令行
pg_restore -d db_development postgres_db.dump
当前回答
为了使用pg_dump创建与pg_restore兼容的备份,在创建转储时必须使用——format=custom / -Fc。
从文档中可以看出:
输出适合输入到pg_restore的自定义格式的存档。
所以你的pg_dump命令可能是这样的:
pg_dump --file /tmp/db.dump --format=custom --host localhost --dbname my-source-database --username my-username --password
你的pg_restore命令:
pg_restore --verbose --clean --no-acl --no-owner --host localhost --dbname my-destination-database /tmp/db.dump
其他回答
如果使用pg_dump和-Fp进行明文备份,则使用以下命令:
cat db.txt | psql dbname
将所有数据复制到名为dbname的数据库
提供了一个简单的回答,这对我有用,对你也适用于大多数情况
psql -U username -d database_name < dump_file.sql . d
如果上面给出与角色相关的错误,则将username替换为postgres。
psql -U postgres -d database_name < dump_file.sql . d
上面的答案对我没用,下面这个有用:
PSQL db_development < postgres_db.dump
psql -U <username> -d <database-name> -h <host-name> -f <backup.sql> . p
如果您恢复。sql文件。 在pgAdmin中创建一个新数据库。 进入终端,浏览.sql文件所在的文件夹/目录。然后在终端中写入以下命令。
让: 超自然用户后
Examaple:
sudo -u postgres psql newDb < restoreDb.sql