使用以下命令以 postgres “自定义”格式origin
转储数据库:pg_dump -d origin --data-only -Fc > file.dump
然后使用转储来恢复具有相同表名的不同数据库中的所有数据,如origin
db. 命令:pg_restore -l -d target --verbose -Fc file.dump
。
;
; Archive created at 2024-03-19 14:00:10 UTC
; dbname: origin
; TOC Entries: 215
; Compression: 0
; Dump Version: 1.13-0
; Format: CUSTOM
; Integer: 4 bytes
; Offset: 8 bytes
; Dumped from database version: 11.18 (Ubuntu 11.18-1.pgdg18.04+1)
; Dumped by pg_dump version: 11.18 (Ubuntu 11.18-1.pgdg18.04+1)
;
;
; Selected TOC Entries:
;
5357; 0 0 ENCODING - ENCODING
5358; 0 0 STDSTRINGS - STDSTRINGS
5359; 0 0 SEARCHPATH - SEARCHPATH
5360; 1262 16387 DATABASE - origin userA
5361; 0 0 DATABASE PROPERTIES - origin userA
; depends on: 5360
5145; 0 730750 TABLE DATA subpartitions backends_y2024w03 userA
; depends on: 237
5166; 0 738268 TABLE DATA subpartitions backends_y2024w04 userA
; depends on: 258
5189; 0 745798 TABLE DATA subpartitions backends_y2024w05 userA
; depends on: 281
.........
- 问题:没有恢复任何内容。如图所示, “自定义”备份转储似乎内部编码了一些
depends on: xxx
注释,而目标数据库中不存在这些注释。将转储转换为纯 SQL 文件,仅包含诸如 之类的命令COPY subpartitions.backends_y2024w03 ("time", dbname, data, tag_data) FROM stdin;
,导入所有数据,没有任何问题。
问题:如何检测丢失的实体,恢复“自定义”备份文件时指的depends on: xxx
是什么以及如何禁用这些检查?(因为示例中存在所有真正的依赖项)xxx
上面显示的输出以 开头,
Archive created ...
表示-l
使用了 (l as Lima) 选项,其中List the table of contents of the archive
.问题是我想要
-1
(第一个)选项single transaction
,但由于我的编辑器和 shell 中的字体,这两个选项看起来完全相同: