1

First off, this is based on Copy a PostgreSQL database into another database. I would gladly expose my problem there, however I have not enough Karma yet to do so.

Here's my code :

sourceDB=$1
targetDB=$2

ssh mgf "createdb $targetDB"
pg_dump -C "$sourceDB" | ssh -C mySSHalias "psql $targetDB"

Here's the output :

SET
SET
SET
SET
SET
SET
ERREUR:  la base de données « mySourceDB » existe déjà
ALTER DATABASE
\connect : option de connexion « -reuse-previous » invalide

So basically my first command is creating a database with $targetDB's name, while my second command try to create a database with $sourceDB's name ?

How to restore at the other end of the pipe with a different name ?

1 Answer 1

2

Omit the -C flag in pg_dump.
This flag causes a CREATE DATABASE statement to be added to the dump file, which is obviously not what you want.

Sign up to request clarification or add additional context in comments.

1 Comment

I am so dumb... Thank you so much !

Your Answer

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.