Automate procedure to resetup postgres replica using pg_basebackup
We quite regularly setup new replicas from scratch. This means cleaning the data directory, taking a basebackup off an upstream node (preferably a secondary) and letting it catch up until in sync with the upstream node.
For an example, see https://gitlab.com/gitlab-com/production/issues/458.
This can be scripted easily. The idea is to start really simple and just provision a script on database hosts that only takes the upstream node (where to connect to) as a parameter and does the rest.
/cc @Finotto
Edited by Andreas Brandl