Skip to content

Instantly share code, notes, and snippets.

@bpaquet
Last active December 30, 2015 00:39
Show Gist options
  • Save bpaquet/7751195 to your computer and use it in GitHub Desktop.
Save bpaquet/7751195 to your computer and use it in GitHub Desktop.
#!/bin/bash
usage() {
echo "sync.sh --from from_path --to to_path [--excl excl_path]"
}
excl_opts=""
while [ ! -z "$1" ]; do
case "$1" in
-f|--from) from=$2 ; shift 2 ;;
-t|--to) to=$2 ; shift 2 ;;
-e|--excl) excl_opts="$excl_opts --exclude=$2" ; shift 2 ;;
*) usage ; exit 2 ;;
esac
done
if [ -z $from -o -z $to ]; then
usage
exit 2
fi
cd $from
from="$(pwd)/"
to="${to%/}/"
echo "Syncing $from to $to"
source /me/workspace/watchdog/bin/activate
opts="-avh --delete --exclude=.git $excl_opts"
rsync $opts $from $to
watchmedo shell-command --command "rsync $opts $from $to" --wait --recursive $from
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment