https://github.com/freddez/pg-dump-filter
Filter tables from PostgreSQL dump
https://github.com/freddez/pg-dump-filter
dump extraction filter postgresql table tool
Last synced: 2 months ago
JSON representation
Filter tables from PostgreSQL dump
- Host: GitHub
- URL: https://github.com/freddez/pg-dump-filter
- Owner: freddez
- License: other
- Created: 2017-11-29T13:31:27.000Z (over 8 years ago)
- Default Branch: master
- Last Pushed: 2018-05-23T14:22:16.000Z (about 8 years ago)
- Last Synced: 2025-10-26T10:30:39.775Z (8 months ago)
- Topics: dump, extraction, filter, postgresql, table, tool
- Language: Rust
- Size: 4.88 KB
- Stars: 3
- Watchers: 1
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
pg-dump-filter
==============
`pg-dump-filter` is a tool that filters tables from a regular
PostgreSQL dump file. It could be used to reload some tables from a
dump in living instance, or to ignore others while creating a test
environment.
Install
-------
This tool is written in [Rust language](https://www.rust-lang.org/).
Install it, then run:
cargo install
Usage
-----
Usage: pg-dump-filter [options]
Options:
-t, --table NAME output only tables matching NAME
-T, --exclude-table NAME
no not output tables matching NAME
-c, --copy-only output only COPY FROM statements
-r, --truncate empty tables before COPY FROM statements
-h, --help print this help menu
Examples
--------
To reload *pool* and *customer* tables datas to an existing database :
pg-dump-filter -cr -t "pool|customer" < dump.sql | psql mydatabase
To load a complete dump excluding *log* datas :
pg-dump-filter -T log < dump.sql | psql mydatabase
Important notice
----------------
Tables arguments folows the [regex rust library
syntax](https://docs.rs/regex/0.2.2/regex/#syntax). For example the
argument:
-t "pool|customer"
matches all `*pool*` and `*customer*` table names. If you want an
exact match, you have to type:
-t "^pool$|^customer$"`
Be warned.
I've written this tool for personal needs. If you find it useful,
don't hesitate to send me some remarks for improvements requests.