mirror of
https://github.com/outbackdingo/patroni.git
synced 2026-01-27 18:20:05 +00:00
Task of restoring a cluster from backup or cloning existing cluster into a new one was floating around for some time. It was kind of possible to achieve it by doing a lot of manual actions and very error prone. So I come up with the idea of making the way how we bootstrap a new cluster configurable. In short - we want to run a custom script instead of running initdb.
22 lines
369 B
Bash
Executable File
22 lines
369 B
Bash
Executable File
#!/bin/bash
|
|
|
|
set -x
|
|
|
|
while getopts ":-:" optchar; do
|
|
[[ "${optchar}" == "-" ]] || continue
|
|
case "${OPTARG}" in
|
|
datadir=* )
|
|
PGDATA=${OPTARG#*=}
|
|
;;
|
|
sourcedir=* )
|
|
SOURCE=${OPTARG#*=}
|
|
;;
|
|
esac
|
|
done
|
|
|
|
[[ -z $PGDATA || -z $SOURCE ]] && exit 1
|
|
|
|
mkdir -p $(dirname $PGDATA)
|
|
|
|
exec cp -af $SOURCE $PGDATA
|