Last active
August 29, 2015 14:24
-
-
Save mikekolganov/ebf8f4d50e0c78d50f13 to your computer and use it in GitHub Desktop.
boot2docker rsync
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 | |
set -u # prevent unbound variables | |
set -e # terminate on error | |
set -o nounset | |
WORKING_DIR=$(pwd) | |
boot2docker ssh " | |
echo 'Checking rsync on boot2docker VM' | |
tce-load -wi rsync | |
sudo mkdir -p $WORKING_DIR | |
sudo chown docker:staff $WORKING_DIR -R | |
" | |
function sync { | |
SSH_PORT=$(boot2docker config 2>&1 | awk '/SSHPort/ {print $3}') | |
rsync -rlz --exclude-from=.rsyncignore -e "ssh -i $HOME/.ssh/id_boot2docker -p $SSH_PORT" -a --force --delete $WORKING_DIR/ docker@localhost:$WORKING_DIR | |
echo "sync: $(date)" | |
return 0 | |
} | |
export -f sync | |
sync | |
if [ $# -gt 0 ] && [ $1 == 'watch' ] | |
then | |
echo "watching directory $WORKING_DIR" | |
fswatch -0 . | xargs -0 -n1 -I{} bash -c "sync" | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
./boot2docker-rsync.sh
— for single sync./boot2docker-rsync.sh watch
— for single sync and start watching changed files to sync