简体   繁体   English

pg_restore旧数据库备份

[英]pg_restore old database backup

Running 9.5 on Ubuntu 16.04 Unsure what database was backed up, I think 8.4 在Ubuntu 16.04上运行9.5不确定要备份的数据库,我认为是8.4

When I run pg_restore I get 当我运行pg_restore我得到

pg_restore: implied data-only restore
--
-- PostgreSQL database dump
--


-- Started on 30608-10-13 11:53:01 MDT

SET statement_timeout = 0;
SET lock_timeout = 0;
SET client_encoding = 'SQL_ASCII';
SET standard_conforming_strings = off;
SET check_function_bodies = false;
SET client_min_messages = warning;
SET escape_string_warning = off;
SET row_security = off;

-- Completed on 2018-09-06 11:12:06 MDT

--
-- PostgreSQL database dump complete
--

When I run pg_restore -l 当我运行pg_restore -l

;
; Archive created at 30608-10-13 11:53:01 MDT
;     dbname: 
;     TOC Entries: -1835365408
;     Compression: -1
;     Dump Version: 1.11-0
;     Format: CUSTOM
;     Integer: 4 bytes
;     Offset: 8 bytes
;
;
; Selected TOC Entries:
;

Obviously there is a timestamp issue, and clearly the TOC entries and compression is off. 显然存在时间戳问题,并且显然TOC条目和压缩已关闭。

Not sure where to go from here. 不知道从这里去哪里。 The file size indicates it should be a complete backup. 文件大小指示它应该是完整的备份。 I have multiple backups from same time frame, and they all report similar when I try to restore them. 我有来自同一时间段的多个备份,当我尝试还原它们时,它们的报告都相似。

Is there any way to uncompress the data portion of the file. 有什么方法可以解压缩文件的数据部分。 I can hexedit and see the schema, but the data is in postgres's binary compressed (-Fc) format. 我可以hexedit并查看架构,但是数据采用的是postgres的二进制压缩(-Fc)格式。 I just need to find and verify a few entries, so if there's a manual way to inspect and search, that would work. 我只需要查找和验证一些条目,因此,如果有手动检查和搜索的方式,则可以使用。

Any help is appreciated. 任何帮助表示赞赏。

Yes, you could extract it just using -f parameter: 是的,您可以仅使用-f参数提取它:

pg_restore -f /path/to/target/file /path/from/source/dump

More info here . 更多信息在这里

I couldn't see the timestamp issue in the output you pasted or I'm missing something. 我在您粘贴的输出中看不到时间戳记问题,或者我丢失了一些东西。

Though, generally, if you would like to restore only few records, you may want to try -L of pg_restore in order to to reorder them and restore. 但是,通常,如果只想还原几个记录,则可能要尝试pg_restore -L以便对它们重新排序并还原。

For example, 例如,

pg_restore -l dbdump > dblist

Edit dblist file (By comment them out or leave only those items you want to restore) 编辑dblist文件(通过将它们注释掉或仅保留要还原的项目)

pg_restore -L dblist dbdump

pg_restore -d newdb dbdump

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM