4

I did the backup of my database:

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

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?

asked May 23, 2018 at 19:06

1 Answer 1

2

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
answered May 24, 2018 at 0:24

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.