Skip to content

Instantly share code, notes, and snippets.

@vandorjw
Last active January 22, 2016 23:59
Show Gist options
  • Select an option

  • Save vandorjw/7f2664ff172b3c7e6169 to your computer and use it in GitHub Desktop.

Select an option

Save vandorjw/7f2664ff172b3c7e6169 to your computer and use it in GitHub Desktop.
#!/bin/sh
# -- ********************************************************************************
# -- Description: Monitoring and sync script for identical remote folders
# -- Version: 0.1
# -- Notes: Ony the folder on the server on which this script resides incurs
# changes. Therefor, we only sync 1 way.
# -- Requires: incron: sudo apt-cache search incron
# using incrontab -e add the following:
# /path/to/folder IN_CLOSE_WRITE /path/to/this/scrip.sh $@/$#
# -- ********************************************************************************
KEY=/path/to/key.pem
RUSER=user
RHOST_1=www.example.com
RHOST_2=www.example.net
PATH=/path/to/folder/
RSYNC=/usr/bin/rsync
SSH=/usr/bin/ssh
# Add additional hosts as required
$RSYNC -az -e "$SSH -i $KEY" $PATH $RUSER@$RHOST_1:$PATH
$RSYNC -az -e "$SSH -i $KEY" $PATH $RUSER@$RHOST_2:$PATH
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment