> Not a bad idea. One that supports rsync and another that supports
> robocopy. That should cover every platform we support.
Example script:
=============================
#!/usr/bin/env bash
# Simple script to copy WAL archives from one server to another
# to be called as archive_command (call this as wal_archive "%p" "%f")
# Settings. Please change the below to match your configuration.
# holding directory for the archived log files on the replica
# this is NOT pg_xlog:
WALDIR="/var/lib/pgsql/archive_logs"
# touch file to shut off archiving in case of filling up the disk:
NOARCHIVE="/var/lib/pgsql/NOARCHIVE"
# replica IP, IPv6 or DNS address:
REPLICA="192.168.1.3"
# put any special SSH options here,
# and the location of RSYNC:
export RSYNC_RSH="ssh"
RSYNC="/usr/bin/rsync"
######## DO NOT CHANGE THINGS BELOW THIS LINE ##########
SOURCE="$1" # %p
FILE="$2" # %f
DEST="${WALDIR}/${FILE}"
# See whether we want all archiving off
test -f ${NOARCHIVE} && exit 0
# Copy the file to the spool area on the replica, error out if
# the transfer fails
${RSYNC} --quiet --archive --rsync-path=${RSYNC} ${SOURCE} \
${REPLICA}:${DEST}
if [ $? -ne 0 ]; then exit 1
fi
--
Josh Berkus
PostgreSQL Experts Inc.
http://pgexperts.com