mble / pgdump-metadata-extractor

Extracts metadata from pg_dumps, outputs it in JSON

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

pgdump-metadata-extractor

lint test

What is this?

This is a small tool to extract some metadata from pg_dump generated dumps of PostgreSQL databases, and present it as JSON.

It does not include the TOC.

Why is this needed?

Sometimes it's handy to have a structured representation of them metadata of a dump.

How can I use it?

This works best as a static binary:

$ make build
$ ./bin/pgdump-metadata-extractor --help
Usage of bin/pgdump-metadata-extractor:
  -filename string
    	dump to read metadata of
  -stdin
    	configure to read from stdin

Then you run it with:

$ ./bin/pgdump-metadata-extractor --filename latest.dump
{"magic":"PGDMP","vmain":1,"vmin":13,"vrev":0,"intsize":4,"offsize":8,"format":"CUSTOM","compression":-1,"timeSec":21,"timeMin":21,"timeHour":17,"timeDay":3,"timeMonth":6,"timeYear":2021,"timeIsDst":1,"database":"bigdb","remoteVersion":"10.11","pgDumpVersion":"10.11","toccount":15}

or

$ ./bin/pgdump-metadata-extractor --stdin < latest.dump
{"magic":"PGDMP","vmain":1,"vmin":13,"vrev":0,"intsize":4,"offsize":8,"format":"CUSTOM","compression":-1,"timeSec":21,"timeMin":21,"timeHour":17,"timeDay":3,"timeMonth":6,"timeYear":2021,"timeIsDst":1,"database":"bigdb","remoteVersion":"10.11","pgDumpVersion":"10.11","toccount":15}

About

Extracts metadata from pg_dumps, outputs it in JSON

License:MIT License


Languages

Language:Go 98.0%Language:Makefile 2.0%