使用旧数据目录恢复新的Postgres数据库

问题描述 投票:0回答:2

我没有从我的旧数据目录进行备份,但我仍然有目录。在我当前的数据库中,我有相同的Schema等...当我尝试恢复数据库(使用pgadmin III)时,我收到此错误:

/Applications/pgAdmin3.app/Contents/SharedSupport/pg_restore --host localhost -- port 5432 -- username "postgres" --dbname "postgres" --role "postgres" --no-password --format directory --verbose "/Library/Postgres/9.5/data" 
pg_restore: [directory archiver] could not open input file "/Library/PostgreSQL/9.5/data/toc.dat": No such file or directory

我不确定toc.dat在哪里发挥作用,因为我不熟悉它。这显然是暂停恢复,但我不知道如何解决这个问题。

postgresql postgresql-9.5
2个回答
1
投票

恢复时不要在参数中使用--format。


0
投票

使用3.0版本的pgAdmin 4

可能为时已晚,但这一直对我有用。

从Current或Old数据库

  1. 启动pgAdmin;
  2. 展开服务器并在其中登录;
  3. 展开PostgreSQL,然后单击要导出/备份的数据库的名称;
  4. 右键单击它以获取选项并选择Backup...;
  5. 在打开的窗口中,输入合适的filename,并确保从下拉菜单中将format设置为Tar;
  6. 然后点击底部的备份;

保存备份文件后

在新数据库或其他数据库上(或在不同的计算机上)

创建一个新数据库并在创建后右键单击它,选择Restore...选项并找到之前创建的Backup up文件。您可能必须选择

Show hidden files and folders选项并将Format设置为All Files

使用此方法不应该出现该错误。

© www.soinside.com 2019 - 2024. All rights reserved.