Skip to content

Instantly share code, notes, and snippets.

@beeradmoore
Created March 28, 2017 22:46
Show Gist options
  • Save beeradmoore/5e3e31c1555a3bf09eb38a0de40a92d0 to your computer and use it in GitHub Desktop.
Save beeradmoore/5e3e31c1555a3bf09eb38a0de40a92d0 to your computer and use it in GitHub Desktop.
Uses fswatch to watch director for changes, and on change upload files with rsync.
#!/bin/sh
USER="someuser"
SERVER="example.com"
LOCAL_DIR="/Users/ytn3rd/somedir/"
REMOTE_DIR="/var/www/htdocs"
PEM_LOCATION="~/.ssh/some_key.pem"
code $LOCAL_DIR
fswatch -o $LOCAL_DIR | xargs -n1 -I{} rsync -avzh -e "ssh -i $PEM_LOCATION" --include=".htaccess" --exclude=".*" --exclude=".*/" --exclude="*.orig" --rsync-path="sudo -Hu apache rsync" --progress $LOCAL_DIR $USER@$SERVER:$REMOTE_DIR
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment