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.
23 lines
523 B
Bash
Executable File
23 lines
523 B
Bash
Executable File
#!/bin/bash
|
|
|
|
while getopts ":-:" optchar; do
|
|
[[ "${optchar}" == "-" ]] || continue
|
|
case "${OPTARG}" in
|
|
datadir=* )
|
|
PGDATA=${OPTARG#*=}
|
|
;;
|
|
dbname=* )
|
|
DBNAME=${OPTARG#*=}
|
|
;;
|
|
walmethod=* )
|
|
WALMETHOD=${OPTARG#*=}
|
|
;;
|
|
esac
|
|
done
|
|
|
|
[[ -z $PGDATA || -z $DBNAME || -z $WALMETHOD ]] && exit 1
|
|
|
|
[[ $WALMETHOD != "none" ]] && WALMETHOD="-X $WALMETHOD" || WALMETHOD=""
|
|
|
|
exec pg_basebackup -D $PGDATA $WALMETHOD -c fast -d $DBNAME
|