Skip to content

Instantly share code, notes, and snippets.

@andreychev
Last active August 29, 2015 14:19
Show Gist options
  • Save andreychev/d127592569e57a7214d2 to your computer and use it in GitHub Desktop.
Save andreychev/d127592569e57a7214d2 to your computer and use it in GitHub Desktop.
new sync
#!/bin/bash
set -u # prevent unbound variables
set -e # terminate on error
SSH_PORT=$(boot2docker config 2>&1 | awk '/SSHPort/ {print $3}')
# install rsync
boot2docker ssh tce-load -wi rsync
# ensure existance of .rsyncignore
touch .rsyncignore
function boot2docker_sync {
# sync current directory to ~/share on the vm
rsync \
-rlz --force --delete \
--exclude-from=.rsyncignore \
-e "ssh \
-o UserKnownHostsFile=/dev/null \
-o StrictHostKeyChecking=no \
-i $HOME/.ssh/id_boot2docker \
-p $SSH_PORT" \
./ docker@localhost:/opt/app
echo "sync: $(date)"
}
export -f boot2docker_sync
boot2docker_sync
fswatch -o . | xargs -n1 -I{} boot2docker_sync
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment