I did the backup of my database:

-bash-4.2$ pg_dump -d mydb --format=custom -f /tmp/dump 

Below checked and I saw my functions there:

-bash-4.2$ pg_restore -l /tmp/dump | grep -i addconf
233; 1255 39949 FUNCTION public addconfiguration(text) mydb
247; 1255 39950 FUNCTION public addconfiguration2(text) mydb
273; 1255 39951 FUNCTION public addconfiguration3(text) mydb

Then I tried to restore one function using the Postgres pg_restore instructions:

-bash-4.2$ pg_restore -d postgres --function=addconfiguration2(text) -v /tmp/dump 
-bash: syntax error near unexpected token `('

I also tried without the parentheses and the arg, but it didn't work:

-bash-4.2$ pg_restore -d postgres --function=addconfiguration2 -v /tmp/dump 
pg_restore: connecting to database for restore
pg_restore: implied data-only restore

After the attempts I verified if the function was created using \df inside psql, but without success.

How could I restore functions using pg_restore?


The parenthesis is special to the shell. You don't have to remove it, you have to quote/escape it to get it to pass through the shell.

pg_restore -d postgres --function='addconfiguration2(text)' -v /tmp/dump

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.