Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
install_pg_rewind.sh
#!/usr/bin/env bash
apt-get -y install postgresql-9.4 postgresql-contrib-9.4 postgresql-server-dev-9.4
###########################################
# Hack alert:
# For Postgresql 9.4, pg_rewind is not in the main source tree and
# no packages exist in the repos, so it must be compiled manually
# and installed on the image until we can move to 9.5
# See README at
# https://github.com/vmware/pg_rewind/tree/REL9_4_STABLE
tmpdir=/tmp/build
mkdir -p $tmpdir
cd $tmpdir
git clone https://github.com/postgres/postgres.git --branch REL9_4_STABLE
cd postgres/contrib
git clone https://github.com/vmware/pg_rewind.git --branch REL9_4_STABLE
dev_pkgs="libreadline-dev libkrb5-dev libssl-dev libpam-dev libxml2-dev libxslt-dev libedit-dev libselinux1-dev bison flex"
apt-get install $dev_pkgs -y
# Unfortunately, on ubuntu, was not able to get pg_rewind to build
# outside of the pgsql source tree. Configure and compile postgres
# but only call make install against the contrib/pg_rewind directory
# so that support library is accessible to the server
cd $tmpdir/postgres
./configure
make
cd contrib/pg_rewind
make install
# Make the pg_rewind binary and the library used by the
# pg_rewind stored procedures accessible
ln -s /usr/local/pgsql/bin/pg_rewind /usr/bin/pg_rewind
ln -s /usr/local/pgsql/lib/pg_rewind_support.so /usr/lib/postgresql/9.4/lib/pg_rewind_support.so
cd
rm -rf $tmpdir
apt-get remove -y $dev_pkgs
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment