Why isn't pg_restore --create working?
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
add a comment |
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
Do you get errors?
– Tom V
Dec 15 '15 at 5:02
No errors, it just quietly puts it all in thepostgres
database.
– Rob N
Dec 15 '15 at 5:24
add a comment |
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
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
postgresql postgresql-9.4 pg-dump pg-restore
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 thepostgres
database.
– Rob N
Dec 15 '15 at 5:24
add a comment |
Do you get errors?
– Tom V
Dec 15 '15 at 5:02
No errors, it just quietly puts it all in thepostgres
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
add a comment |
1 Answer
1
active
oldest
votes
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
New contributor
add a comment |
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
});
}
});
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
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
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
New contributor
add a comment |
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
New contributor
add a comment |
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
New contributor
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
New contributor
New contributor
answered 1 hour ago
Andres Leon RangelAndres Leon Rangel
34
34
New contributor
New contributor
add a comment |
add a comment |
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.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
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
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
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
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