Skip to content

KeithBerson/postgres_dump_parser

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

postgres_dump_parser

Overview

This application takes a schema dump from a database (pg_dump -s), parses it into chunks, and saves the chunk based on the type that it is. This is a command line tool, intended to be run in a terminal window, with the DB dump file as input, along with a specified destination folder.

Running

Open a terminal and from the command line, enter:

postgres_dump_parser -d {DB_dump_file} -o {output_path} [-n][-s][-s][-f][-v]

where:
    -d {DB_dump_file}   the saved output produced by running 'pg_dump -s'
    -o {output_folder}  the location where the parser should put its output (must exist)
    -n                  don't clear (files and folders in the output folder are deleted by default)
    -p                  save search paths
    -s                  silent mode
    -f                  turn 'default_with_oids' filter off
    -v                  verbose

The DB_dump_file is required and is the output of a pg_dump -s command. The output path is where you want the results to be saved (the path must exist). As postgres_dump_parser runs, it creates subfolders in the output path of the various types of entities that can be found in a Postgres DB, such as TYPE, CONTRAINT, INDEX, SEQUENCE, SCHEMA, TABLE and more. The entities are stored in SQL files of the name as found in the entry.

Sample of an INDEX entry chunk:

--
--/home/keith/data/pc_chain_production.dmp    2024-07-19 11:35:01
--shopperid_index.sql    #INDEX 10
--

--
-- Name: shopperid_index; Type: INDEX; Schema: inmar; Owner: postgres; Tablespace: 
--

CREATE INDEX shopperid_index ON shopper_access_tokens USING btree (shopperid);

Each entry shows the name of the DB dump file it was generated from and the date it was produced. It includes the name of the SQL file as well as the type and the count number.

In addition, postgres_dump_parser generates a file that keeps the Order Of Build, as this is important for reconstruction of the DB from these files, if it is ever necessary. The files is named order_of_build.

Building postgres_dump_parser

The application needs to be compiled using at least C++14. A makefile is included in the project.

Open a terminal in the project folder and enter:

make [clean] [all]

Documentation

Documentation for the project has been generated using doxygen 1.11.0.

To access the documentation, open the index.html file in html folder

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published