pg.ddx.io  pgsql-general@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Tom Lane <tgl@sss.pgh.pa.us>
To: Adrian Klaver <adrian.klaver@aklaver.com>
Cc: Joao Miguel Ferreira <joao.miguel.c.ferreira@gmail.com>
Cc: pgsql-general <pgsql-general@lists.postgresql.org>
Subject: Re: pg_dumpall and tablespaces
Date: Tue, 02 Feb 2021 12:08:19 -0500
Message-ID: <3719306.1612285699@sss.pgh.pa.us> (raw)
In-Reply-To: <aefc0690-e394-4ea3-7006-9ea79204e497@aklaver.com>
References: <CALyyT7R8NcVvazqF_-Xg4EkUM9KYAkmGBUv_NXA2TFZox9rGnw@mail.gmail.com>
	<aefc0690-e394-4ea3-7006-9ea79204e497@aklaver.com>

Adrian Klaver <adrian.klaver@aklaver.com> writes:
> On 2/2/21 8:43 AM, Joao Miguel Ferreira wrote:
>> I have a dump file obtained from pg_dumpall on a MAC computer. I need to 
>> load in onto my Linux laptop running postgres.
>> I got 2 problems concerning tablespaces:
>> a) during the restore step I get lots of errors about the necessity to 
>> have root permissions to re-create the tablespaces and
>> b) the tablespaces paths on the dump file are bound to the MAC 
>> filesystem (/Users/..../pg/....). I would need to re-write that path to 
>> my home folder or '/var/lib/....'

> Do you want to maintain tablespaces on the dev machine?

> If not from here:
> https://www.postgresql.org/docs/12/app-pg-dumpall.html
> --no-tablespaces

Also, if you're not in a position to re-make the dump file, you
can just restore it and ignore all the tablespace-related errors.
You'll end up with the same situation either way, i.e. all the
tables exist in the default tablespace.

If you do need to preserve the separation into distinct tablespaces,
you could try this:

* Starting with an empty installation, create the tablespaces you need,
matching the original installation's tablespace names but putting
the directories wherever is handy.

* Restore the dump, ignoring the errors about tablespaces already
existing.

Either way, the key is that a dump file is just a SQL script and
isn't especially magic; you don't have to be in fear of ignoring
a few errors.  pg_dump builds the script to be resistant to certain
types of issues, and missing tablespaces is one of those.

I do recommend capturing the stderr output and checking through it
to ensure you didn't have any unexpected errors.

			regards, tom lane





view thread (5+ messages)  latest in thread

Message-ID: <3719306.1612285699@sss.pgh.pa.us>
Permalink:  ../3719306.1612285699@sss.pgh.pa.us/
Also on:    postgresql.org/message-id/3719306.1612285699@sss.pgh.pa.us

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-general@postgresql.org
  Cc: tgl@sss.pgh.pa.us, adrian.klaver@aklaver.com, joao.miguel.c.ferreira@gmail.com
  Subject: Re: pg_dumpall and tablespaces
  In-Reply-To: <3719306.1612285699@sss.pgh.pa.us>
  References: <CALyyT7R8NcVvazqF_-Xg4EkUM9KYAkmGBUv_NXA2TFZox9rGnw@mail.gmail.com> <aefc0690-e394-4ea3-7006-9ea79204e497@aklaver.com> <3719306.1612285699@sss.pgh.pa.us>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox