simple cli to load pg database schema and save all of the tables content as csv
/json
files in a folder.
i had use case where i needed some tool to backup postgres db tables to files, this does that in a simple way.
NOTE, THIS IS NOT INTENDED AS PRODUCTION BACKUP TOOL, ONLY FOR SIMPLE FILE EXPORTS.
i should mention @LORENZO ALBERTON article it was very helpful in extracting db schema check it out here EXTRACTING META INFORMATION FROM POSTGRESQL (INFORMATION_SCHEMA)
for more information check postgres docs.
if you need production backup tool use pg_dump instead, but i would recommend using your db provider backup functionality.
this project uses bun
-
install deps
bun install
-
the cli is built using commander so you can run
bun start --help
to see available commands
-
extract as json
bun start json
-
extract as csv
bun start csv
-
apply some json dump
bun start apply <folderPath>
problems need to be fixed
-
you need to know the relation between the tables so when re-pushing them to db you don't break the "data integrity" https://gist.github.com/ststeiger/2ed2612f0a7fa09f20c2cc4882dc3f5b https://stackoverflow.com/questions/51279588/sort-tables-in-order-of-dependency-postgres
-
date gets fucked(timezone shit i HATE ITTTTT)