Last active
December 30, 2015 00:39
-
-
Save bpaquet/7751195 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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