pgcopydb icon indicating copy to clipboard operation
pgcopydb copied to clipboard

Cloning a whole instance/CREATE DATABASE support?

Open troelsarvin opened this issue 9 months ago • 2 comments

I'm involved in a database server migration task where I need to move all databases from an old server to a fresh Postgres installation. For this, I'd like to have pgcopydb clone all databases, except for postgres, template0, and template1. And cloning should include CREATE DATABASE. I don't see a way do clone a whole instance/cluster; am I overlooking something?

If it's not possible to clone a whole instance, I can of course generate a list of DB names and loop over them in calls to pgcopydb, but then it would be very useful if pgcopydb could handle the CREATE DATABASE step, as well as the DDL and data cloning. I don't see a way to have pgcopydb handle database creation on the destination side, am I overlooking something?

If I'm trying to use pgcopydb in a way which is not intended: Can someone propose a different tool? - I.e. one which doesn't involve temporary dump files which need space and one which handles primary key indices in a clever way like pgcopydb does.

troelsarvin avatar Nov 09 '23 08:11 troelsarvin

Hi @troelsarvin ; thanks for using pgcopydb and reporting a wishlist item. Support for multiple databases in a way that allows sharing resources (table jobs, index jobs, etc) between them is on the TODO list. Some changes are currently happening to the internal memory model of the catalogs in pgcopydb, and after that I think it will be much easier to tackle the problem.

Are you interested in working on the implementation of the feature?

dimitri avatar Nov 09 '23 14:11 dimitri

I cannot contribute C code, unfortunately. I'd be happy to test unreleased code.

Sharing of resources: If that means keeping the copy-process busy across different databases, then: That is not important for me. What would be really useful would for the tool to be able to issue the proper CREATE DATABASE statements and itself discover which databases exist (and thus need to be copied).

troelsarvin avatar Nov 09 '23 19:11 troelsarvin