postgis_restore(1)

πŸ“¦
version 3.6.4 Β· 2 versions
  • 3.6.4 Β· alpine 3.24, arch rolling, centos-stream 10, centos-stream 9, debian trixie, fedora 43, fedora 44, nixos 26.05, nixpkgs unstable, ubuntu questing, ubuntu resolute, ubuntu stonking (latest)
  • 3.4.2 Β· ubuntu noble
, in alpine 3.24, arch rolling, centos-stream 10, centos-stream 9, debian trixie, fedora 43, fedora 44, nixos 26.05, nixpkgs unstable, ubuntu questing, ubuntu resolute, ubuntu stonking

πŸ’– postgis_restore(1) πŸ’–

okay bestie, so this is postgis_restore, and it lives in the PostGIS manual, section 1. it's a lil script that pulls your data back out of a dump file, and it's about to become your whole personality. no cap.


✨ NAME ✨

postgis_restore β€” restore a PostGIS database from an archive file created by pg_dump


🌸 SYNTAX 🌸

postgis_restore [-v] [-L TOC] [-s schema] dumpfile

like. that's the whole vibe. you give it a dumpfile and it does the thing 🫢


πŸ¦‹ DESCRIPTION πŸ¦‹

so the postgis_restore command lets you extract SQL statements that re-create all the objects hanging out in a custom dump of a PostGIS-enabled database… while skipping the PostGIS specific objects. it's giving "here's your stuff, minus the PostGIS internals." πŸ’…

this is only useful for dumps of databases where PostGIS got enabled by loading the postgis.sql script. iykyk.

⚠️ if your dump came from a database where PostGIS was enabled via CREATE EXTENSION, that dump will not have PostGIS objects in it at all β€” so it's totally safe to restore it directly using pg_restore. no detour needed, bestie.

also, heads up fr fr: this command only works with dumps using the custom format, which are the ones you make with pg_dump -Fc. any other format? not it. 😭


πŸŽ€ USAGE πŸŽ€

run the script with no arguments and it'll print usage information for you. it's polite like that. ✨


πŸ”₯ EXAMPLES πŸ”₯

step 1 β€” create a custom dump from olddb:

pg_dump -Fc olddb > olddb.dump

step 2 β€” create a new database newdb:

createdb newdb

step 3 β€” PostGIS-enable the new database:

psql -c 'CREATE EXTENSION postgis' newdb

step 4 β€” restore your data (the main character moment):

postgis_restore.pl olddb.dump | psql newdb

ate. no crumbs. πŸ‘‘


πŸ‘‘ AUTHORS πŸ‘‘

originally written by Sandro Santilli <strk@kbt.io>. absolute icon behavior.

more information is available at http://postgis.net 🌈


so yeah β€” that's the whole page, straight from the PostGIS manual, section 1, and the page you just read is literally titled postgis_restore(1). mwah. go restore something. πŸ’–βœ¨πŸŽ€πŸ¦‹πŸŒΈπŸ’…πŸ«Ά