Reputation: 134
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 ?
Upvotes: 1
Views: 1024
Reputation: 247465
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.
Upvotes: 2