Skip to content

Instantly share code, notes, and snippets.

@sfoster
Last active January 29, 2016 16:51
Show Gist options
  • Save sfoster/033f243ace3f0d67b3c3 to your computer and use it in GitHub Desktop.
Save sfoster/033f243ace3f0d67b3c3 to your computer and use it in GitHub Desktop.
#!/bin/bash
# synch files across a local project directory to a remote server
# place pisync.sh at the top of your project directory, or alias it
# ip or hostname of the pi
REMOTE_HOST=10.0.1.15
# path to the project directory on the pi
PROJECT=/home/pi/mirror
BASE_DIR=$(dirname $(readlink -f $0))
WDIR=`pwd`
DIR=${WDIR#${BASE_DIR}}
EXCLUDES="node_modules"
echo relative path: $DIR, sync to $REMOTE_HOST:$PROJECT
# push
rsync -a --exclude $EXCLUDES ./ pi@$REMOTE_HOST:$PROJECT/${DIR:1}/
# then pull
rsync -a --exclude $EXCLUDES pi@$REMOTE_HOST:$PROJECT/${DIR:1}/ ./
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment