Skip to content

Instantly share code, notes, and snippets.

@niklasl
Created October 28, 2017 21:02
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save niklasl/c3c6750e2c4198ec0821e741e0b77b0b to your computer and use it in GitHub Desktop.
Save niklasl/c3c6750e2c4198ec0821e741e0b77b0b to your computer and use it in GitHub Desktop.
Crude fallback when unison isn't available on your local machine. (Note that this method stores duplicates of the files of interest on the server.)
# Paths of interest
LOCALDIR=syncdir
HOST=user@example.org
LANDINGDIR=landingdir
TARGETDIR=syncdir
# Sync files from local device to the server landing dir
rsync -auv --delete $LOCALDIR/ $HOST:$LANDINGDIR
# Two-way-sync the landing dir with the target dir
ssh $HOST "
unison $LANDINGDIR $TARGETDIR \
-path paths/of/interest \
-path general/notes \
-path work/project
" || echo # suppress potential non-zero exit ...
# Get eventual changes back to local device
rsync -auv --delete $HOST:$LANDINGDIR/ $LOCALDIR
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment