Skip to content

Instantly share code, notes, and snippets.

@Geesu
Created January 26, 2014 23:00
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Geesu/8640616 to your computer and use it in GitHub Desktop.
Save Geesu/8640616 to your computer and use it in GitHub Desktop.
Postgresql replication archive_command
#!/bin/bash
echoerr() { echo "$@" 1>&2; }
FAIL=0
`rsync -aq $1 postgres@b:/var/lib/postgresql/9.2/archive/$2` & pid_1=$! ; `rsync -aq $1 postgres@c:/var/lib/postgresql/9.2/archive/$2` & pid_2=$! ; `rsync -aq $1 postgres@d:/var/lib/postgresql/9.2/archive/$2` & pid_3=$!
echoerr "Spawned replication processes $pid_1 AND $pid_2 AND $pid_3"
wait $pid_1 || let "FAIL+=1"
wait $pid_2 || let "FAIL+=1"
wait $pid_3 || let "FAIL+=1"
if [ "$FAIL" == "0" ];
then
echoerr "Replication success $1 $2"
else
echoerr "Replication failed $1 $2"
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment