PostgreSQL pg_basebackup 缺少 toc.dat 头文件

PostgreSQL pg_basebackup missing toc.dat header file

我正在使用以下命令备份我的数据库 (PostgreSQL 11.8):

pg_basebackup -D "C:\temp" -F tar -X f -z -P -U myUser

并恢复以下内容:

  1. 我手动解压 base.tar.gz => base.tar
  2. pg_restore -h localhost -W -U myUser -c -C -d myDatabase -F tar -v "C:\temp\base.tar"

这会导致以下错误:

pg_restore: [tar archiver] could not find header for file "toc.dat" in tar archive

我做错了什么? 另外,我尝试了不同版本的还原(仅数据等),但当然丢失头文件的问题仍然存在。

感谢您的帮助!

您不能同时使用 pg_basebackup 和 pg_restore:

  • pg_basebackup 是一个 物理 备份工具
  • pg_restore 只能与 pg_dump.
  • 创建的 逻辑 备份一起使用

没有单个 PostgreSQL 命令可以恢复使用 pg_basebackup 创建的备份。

要还原物理备份,请参阅https://www.postgresql.org/docs/12/continuous-archiving.html#BACKUP-PITR-RECOVERY