Skip to content

Instantly share code, notes, and snippets.

@aotd1
Created January 19, 2015 13:28
Show Gist options
  • Save aotd1/c6fd01af1262bafa6187 to your computer and use it in GitHub Desktop.
Save aotd1/c6fd01af1262bafa6187 to your computer and use it in GitHub Desktop.
Simple script to start replication on slave postgresql 9.3
#!/bin/bash
PATH="/bin:/sbin:/usr/bin:/usr/sbin"
TARGETDIR=/var/lib/postgresql/9.3/main/
test -z "$1" && { echo 'Please specify argument: source master base host' 2>&1; exit 1; }
service postgresql stop
rm -rf $TARGETDIR
pg_basebackup --verbose --checkpoint=fast --xlog-method=stream -U postgres --pgdata="$TARGETDIR" --host="$1"
chown -R postgres:postgres $TARGETDIR
ln -s /etc/postgresql/9.3/main/recovery.conf $TARGETDIR/recovery.conf
ln -s /etc/ssl/certs/ssl-cert-snakeoil.pem $TARGETDIR/server.crt
ln -s /etc/ssl/private/ssl-cert-snakeoil.key $TARGETDIR/server.key
service postgresql start
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment