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

时间:2016-07-05 18:19:27

标签: postgresql postgresql-9.5

我没有从我的旧数据目录进行备份,但我仍然有目录。在我当前的数据库中,我有相同的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在哪里发挥作用,因为我不熟悉它。这显然是暂停恢复,但我不知道如何解决这个问题。

2 个答案:

答案 0 :(得分:1)

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

答案 1 :(得分:0)

使用 pgAdmin 4的 3.0版本

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

从当前或旧数据库中

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

备份文件一旦保存

在“新建”或“其他”数据库上(或在其他计算机上)

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

  

Show hidden files and folders   选项和设置   FormatAll Files

使用此方法不应遇到该错误。

相关问题