Re: Migration struggles

From: Vijaykumar Jain <vijaykumarjain(dot)github(at)gmail(dot)com>
To: Christian Lehmann <info(at)chlehmann(dot)ch>
Cc: Pgsql-admin <pgsql-admin(at)lists(dot)postgresql(dot)org>
Subject: Re: Migration struggles
Date: 2021-08-03 14:50:59
Message-ID: CAM+6J96iPLk+LQ4asWBxX61oOVE_R1EJKqcH7UV-ZG_kjsF3Lg@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-admin

On Tue, 3 Aug 2021 at 20:01, Christian Lehmann <info(at)chlehmann(dot)ch> wrote:

> Hi all
> i am currently building a ansible-managed pg13-cluster. Ansible not
> only configures postgres pgbouncer etc but also creates roles and
> manages pg_hba.
>
> Now I am planning and documenting the upcoming migration. Do you have
> a good idea, how i could proceed without a lot of sed'ing or similar
> hacky things?
>
> - if i use pg_dumpall, i have the "create role"-statements which will fail
> - if i use pg_dump i have to backup all db's one by one
> - pg_dumpall -a only gives me the data, -s is only the schema. This
> might be the most promising approach, backing up schema, then data and
> importing it on the new server. But still it would be more convenient
> to just run one command.
>

I have not done a migration using config management,
but ansible like other config management tools should be idempotent iirc.
you can run as many times as you want, the runs are mostly noops if the
desired state is already attained imho.

so, in that case when you run a dump all using
-c, --clean clean (drop) databases before recreating
--if-exists use IF EXISTS when dropping objects

this would drop the objects before recreating, so restore should run fine.
and later ansible runs, should restore anything that is not a part of db
restoration just fine.

but i have not done a migration using cfg mgmt tools, so just my opinion.

pg_dumpall -c --if-exists > dump.sql

--

Thanks,
Vijay
Mumbai, India

In response to

Responses

Browse pgsql-admin by date

  From Date Subject
Next Message Christian Lehmann 2021-08-03 14:55:28 Re: Migration struggles
Previous Message Ron 2021-08-03 14:50:03 Re: Migration struggles