Search code examples
postgresqlgoogle-cloud-platformdevopsstaging

Replicate different instance's databases into one instance with multiple databases


I'm running multiple Cloud SQL with Postgres at GCP in my Production app. I'm willing to create a staging environment and use the same data we are using in production. Our production databases are something like this:

Instance1:

  • database-a
  • database-b
  • database-c

Instance2:

  • database-d
  • database-e
  • ...

Is it possible to create a replica instance, joining all the databases, like this?:

Instance-STG:

  • database-a
  • database-b
  • database-c
  • database-d
  • database-e

Solution

  • Short Answer: Not Automatically A replica can only copy from master and will not join anything.

    However, if you merge the databases in your master, replica will copy that.

    I could be wrong, but what you are looking for is to "migrate databases" to one instance from multiple sources. These databases will not be in sync with the original ones unless you make them via CDC. You can make use of external tools to achieve so, one of such tool is "Striim" or use this . This way may achieve your final instance.

    Note: CDC will consume resources on instances (memory, performance etc).