Why isn't pg_restore --create working?












1














I backed up a database called app_data, on a 9.3 server, with this basic command:



pg_dump -n public -F custom app_data > app_data.pg.dump


Then I try to restore it on another server (running 9.4) like this:



pg_restore -C -d postgres app_data.pg.dump 


But it puts all the tables in the postgres database. The man page says it will create and use a new database, app_data.




-C --create



Create the database before restoring into it. [...]



When this option is used, the database named with -d is used only to issue the initial DROP DATABASE and CREATE DATABASE commands. All data is
restored into the database name that appears in the archive.




That's not what it's doing. The name in the archive is app_data:



bash-4.2$ pg_restore -l app_data.pg.dump 
;
; Archive created at Tue Dec 15 04:16:52 2015
; dbname: app_data
...


Am I doing something wrong?










share|improve this question






















  • Do you get errors?
    – Tom V
    Dec 15 '15 at 5:02










  • No errors, it just quietly puts it all in the postgres database.
    – Rob N
    Dec 15 '15 at 5:24
















1














I backed up a database called app_data, on a 9.3 server, with this basic command:



pg_dump -n public -F custom app_data > app_data.pg.dump


Then I try to restore it on another server (running 9.4) like this:



pg_restore -C -d postgres app_data.pg.dump 


But it puts all the tables in the postgres database. The man page says it will create and use a new database, app_data.




-C --create



Create the database before restoring into it. [...]



When this option is used, the database named with -d is used only to issue the initial DROP DATABASE and CREATE DATABASE commands. All data is
restored into the database name that appears in the archive.




That's not what it's doing. The name in the archive is app_data:



bash-4.2$ pg_restore -l app_data.pg.dump 
;
; Archive created at Tue Dec 15 04:16:52 2015
; dbname: app_data
...


Am I doing something wrong?










share|improve this question






















  • Do you get errors?
    – Tom V
    Dec 15 '15 at 5:02










  • No errors, it just quietly puts it all in the postgres database.
    – Rob N
    Dec 15 '15 at 5:24














1












1








1







I backed up a database called app_data, on a 9.3 server, with this basic command:



pg_dump -n public -F custom app_data > app_data.pg.dump


Then I try to restore it on another server (running 9.4) like this:



pg_restore -C -d postgres app_data.pg.dump 


But it puts all the tables in the postgres database. The man page says it will create and use a new database, app_data.




-C --create



Create the database before restoring into it. [...]



When this option is used, the database named with -d is used only to issue the initial DROP DATABASE and CREATE DATABASE commands. All data is
restored into the database name that appears in the archive.




That's not what it's doing. The name in the archive is app_data:



bash-4.2$ pg_restore -l app_data.pg.dump 
;
; Archive created at Tue Dec 15 04:16:52 2015
; dbname: app_data
...


Am I doing something wrong?










share|improve this question













I backed up a database called app_data, on a 9.3 server, with this basic command:



pg_dump -n public -F custom app_data > app_data.pg.dump


Then I try to restore it on another server (running 9.4) like this:



pg_restore -C -d postgres app_data.pg.dump 


But it puts all the tables in the postgres database. The man page says it will create and use a new database, app_data.




-C --create



Create the database before restoring into it. [...]



When this option is used, the database named with -d is used only to issue the initial DROP DATABASE and CREATE DATABASE commands. All data is
restored into the database name that appears in the archive.




That's not what it's doing. The name in the archive is app_data:



bash-4.2$ pg_restore -l app_data.pg.dump 
;
; Archive created at Tue Dec 15 04:16:52 2015
; dbname: app_data
...


Am I doing something wrong?







postgresql postgresql-9.4 pg-dump pg-restore






share|improve this question













share|improve this question











share|improve this question




share|improve this question










asked Dec 15 '15 at 4:47









Rob NRob N

1062




1062












  • Do you get errors?
    – Tom V
    Dec 15 '15 at 5:02










  • No errors, it just quietly puts it all in the postgres database.
    – Rob N
    Dec 15 '15 at 5:24


















  • Do you get errors?
    – Tom V
    Dec 15 '15 at 5:02










  • No errors, it just quietly puts it all in the postgres database.
    – Rob N
    Dec 15 '15 at 5:24
















Do you get errors?
– Tom V
Dec 15 '15 at 5:02




Do you get errors?
– Tom V
Dec 15 '15 at 5:02












No errors, it just quietly puts it all in the postgres database.
– Rob N
Dec 15 '15 at 5:24




No errors, it just quietly puts it all in the postgres database.
– Rob N
Dec 15 '15 at 5:24










1 Answer
1






active

oldest

votes


















0














Yes that behaviour is something that I should report to postgres as use of different flags doesnt seem to have an effect and it just doesnt work. To solve it use:




  • create DB


createdb -h HOST -U USER -W DB_NAME




  • restore and in case of Error Stop


egrep -v 'EXTENSION.*plpgsql' DUMPFILE.sql | psql -h HOST -U USER -W -d DB_NAME -v ON_ERROR_STOP=1






share|improve this answer








New contributor




Andres Leon Rangel is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.


















    Your Answer








    StackExchange.ready(function() {
    var channelOptions = {
    tags: "".split(" "),
    id: "182"
    };
    initTagRenderer("".split(" "), "".split(" "), channelOptions);

    StackExchange.using("externalEditor", function() {
    // Have to fire editor after snippets, if snippets enabled
    if (StackExchange.settings.snippets.snippetsEnabled) {
    StackExchange.using("snippets", function() {
    createEditor();
    });
    }
    else {
    createEditor();
    }
    });

    function createEditor() {
    StackExchange.prepareEditor({
    heartbeatType: 'answer',
    autoActivateHeartbeat: false,
    convertImagesToLinks: false,
    noModals: true,
    showLowRepImageUploadWarning: true,
    reputationToPostImages: null,
    bindNavPrevention: true,
    postfix: "",
    imageUploader: {
    brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
    contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
    allowUrls: true
    },
    onDemand: true,
    discardSelector: ".discard-answer"
    ,immediatelyShowMarkdownHelp:true
    });


    }
    });














    draft saved

    draft discarded


















    StackExchange.ready(
    function () {
    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fdba.stackexchange.com%2fquestions%2f123690%2fwhy-isnt-pg-restore-create-working%23new-answer', 'question_page');
    }
    );

    Post as a guest















    Required, but never shown

























    1 Answer
    1






    active

    oldest

    votes








    1 Answer
    1






    active

    oldest

    votes









    active

    oldest

    votes






    active

    oldest

    votes









    0














    Yes that behaviour is something that I should report to postgres as use of different flags doesnt seem to have an effect and it just doesnt work. To solve it use:




    • create DB


    createdb -h HOST -U USER -W DB_NAME




    • restore and in case of Error Stop


    egrep -v 'EXTENSION.*plpgsql' DUMPFILE.sql | psql -h HOST -U USER -W -d DB_NAME -v ON_ERROR_STOP=1






    share|improve this answer








    New contributor




    Andres Leon Rangel is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
    Check out our Code of Conduct.























      0














      Yes that behaviour is something that I should report to postgres as use of different flags doesnt seem to have an effect and it just doesnt work. To solve it use:




      • create DB


      createdb -h HOST -U USER -W DB_NAME




      • restore and in case of Error Stop


      egrep -v 'EXTENSION.*plpgsql' DUMPFILE.sql | psql -h HOST -U USER -W -d DB_NAME -v ON_ERROR_STOP=1






      share|improve this answer








      New contributor




      Andres Leon Rangel is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
      Check out our Code of Conduct.





















        0












        0








        0






        Yes that behaviour is something that I should report to postgres as use of different flags doesnt seem to have an effect and it just doesnt work. To solve it use:




        • create DB


        createdb -h HOST -U USER -W DB_NAME




        • restore and in case of Error Stop


        egrep -v 'EXTENSION.*plpgsql' DUMPFILE.sql | psql -h HOST -U USER -W -d DB_NAME -v ON_ERROR_STOP=1






        share|improve this answer








        New contributor




        Andres Leon Rangel is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
        Check out our Code of Conduct.









        Yes that behaviour is something that I should report to postgres as use of different flags doesnt seem to have an effect and it just doesnt work. To solve it use:




        • create DB


        createdb -h HOST -U USER -W DB_NAME




        • restore and in case of Error Stop


        egrep -v 'EXTENSION.*plpgsql' DUMPFILE.sql | psql -h HOST -U USER -W -d DB_NAME -v ON_ERROR_STOP=1







        share|improve this answer








        New contributor




        Andres Leon Rangel is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
        Check out our Code of Conduct.









        share|improve this answer



        share|improve this answer






        New contributor




        Andres Leon Rangel is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
        Check out our Code of Conduct.









        answered 1 hour ago









        Andres Leon RangelAndres Leon Rangel

        34




        34




        New contributor




        Andres Leon Rangel is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
        Check out our Code of Conduct.





        New contributor





        Andres Leon Rangel is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
        Check out our Code of Conduct.






        Andres Leon Rangel is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
        Check out our Code of Conduct.






























            draft saved

            draft discarded




















































            Thanks for contributing an answer to Database Administrators Stack Exchange!


            • Please be sure to answer the question. Provide details and share your research!

            But avoid



            • Asking for help, clarification, or responding to other answers.

            • Making statements based on opinion; back them up with references or personal experience.


            To learn more, see our tips on writing great answers.





            Some of your past answers have not been well-received, and you're in danger of being blocked from answering.


            Please pay close attention to the following guidance:


            • Please be sure to answer the question. Provide details and share your research!

            But avoid



            • Asking for help, clarification, or responding to other answers.

            • Making statements based on opinion; back them up with references or personal experience.


            To learn more, see our tips on writing great answers.




            draft saved


            draft discarded














            StackExchange.ready(
            function () {
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fdba.stackexchange.com%2fquestions%2f123690%2fwhy-isnt-pg-restore-create-working%23new-answer', 'question_page');
            }
            );

            Post as a guest















            Required, but never shown





















































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown

































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown







            Popular posts from this blog

            Liste der Baudenkmale in Friedland (Mecklenburg)

            Single-Malt-Whisky

            Czorneboh