Re: Migration struggles - Mailing list pgsql-admin

From Vijaykumar Jain
Subject Re: Migration struggles
Date
Msg-id CAM+6J96iPLk+LQ4asWBxX61oOVE_R1EJKqcH7UV-ZG_kjsF3Lg@mail.gmail.com
Whole thread Raw
In response to Migration struggles  (Christian Lehmann <info@chlehmann.ch>)
Responses Re: Migration struggles  (Christian Lehmann <info@chlehmann.ch>)
List pgsql-admin
On Tue, 3 Aug 2021 at 20:01, Christian Lehmann <info@chlehmann.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

pgsql-admin by date:

Previous
From: Ron
Date:
Subject: Re: Migration struggles
Next
From: Christian Lehmann
Date:
Subject: Re: Migration struggles