Skip site navigation (1) Skip section navigation (2)

Re: running COPY with remote DB and local file

From: Michael Wood <esiotrot(at)gmail(dot)com>
To: Majid Azimi <majid(dot)merkava(at)gmail(dot)com>
Cc: pgsql-novice <pgsql-novice(at)postgresql(dot)org>
Subject: Re: running COPY with remote DB and local file
Date: 2012-03-06 10:00:23
Message-ID: CAP6d-HUGAJvwyZdOPVYwnFffmDJpNKG51TehU=xz5Ej_Z8Q57Q@mail.gmail.com (view raw or flat)
Thread:
Lists: pgsql-novice
On 6 March 2012 11:08, Majid Azimi <majid(dot)merkava(at)gmail(dot)com> wrote:
> hi guys,
>
> I'm going to run COPY from a shell script. But this script is running
> on my local PC. The database is not local. Now which permission should
> the output file?This is the command:
>
> psql -U <user> -h <remote_ip> -d testdb -c "COPY (SELECT * FROM
> main.data) TO /home/backup.sql WITH CSV HEADER;"
>
> postgresql doc says:
>
> Files named in a COPY command are read or written directly by the
> server, not by the client application. Therefore, they must reside on
> or be accessible to the database server machine, not the client. They
> must be accessible to and readable or writable by the PostgreSQL user
> (the user ID the server runs as), not the client.
>
> I'm confused about permissions of the output when the DB is remote and
> the output file is local.

No you have misunderstood the documentation.

What it is trying to say is that your COPY command will try to create
a file ON THE SERVER called /home/backup.sql.

-- 
Michael Wood <esiotrot(at)gmail(dot)com>

In response to

pgsql-novice by date

Next:From: Julien RouhaudDate: 2012-03-06 10:44:38
Subject: Re: [ADMIN] pg_dump : no tables were found.
Previous:From: Majid AzimiDate: 2012-03-06 09:09:32
Subject: Re: Database not browsable during COPY on PostgreSQL

Privacy Policy | About PostgreSQL
Copyright © 1996-2014 The PostgreSQL Global Development Group