Skip to content

Instantly share code, notes, and snippets.

@denitram
Last active July 10, 2023 11:09
Show Gist options
  • Save denitram/9368976 to your computer and use it in GitHub Desktop.
Save denitram/9368976 to your computer and use it in GitHub Desktop.
Postgresql: backup and restore functions
# First, make a dump of the database without data (-s)
$ pg_dump -h localhost -U username -Fc -s -f db_dump dbName
# Create a list of the functions
$ pg_restore -l db_dump | grep FUNCTION > function_list
# Restore the functions in an other database
$ pg_restore -h localhost -U username -d other-dbName -L function_list db_dump
@lodwig
Copy link

lodwig commented Apr 21, 2022

Hi denitram, Thank you for saving my time.
It's Better if you can do it for tables on database to.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment