Skip to content

Instantly share code, notes, and snippets.

@xelwarto xelwarto/auto-rsync
Created Mar 25, 2017

Embed
What would you like to do?
Automatic rsync script for use in vagrants
#!/usr/bin/env bash
SRC=""
DEST=""
TMP_FILE="/tmp/auto_rsync_"
PAUSE="10"
while getopts ":s:d:p:" OPTS; do
case $OPTS in
s)
SRC="$OPTARG"
;;
d)
DST="$OPTARG"
;;
p)
PAUSE="$OPTARG"
;;
\?)
echo "Invalid option: -$OPTARG" >&2
exit 1
;;
esac
done
if [ -z "$SRC" ] ; then
echo "Source not provided"
exit 1
fi
if [ -z "$DST" ] ; then
echo "Destination not provided"
exit 1
fi
echo "Performing initial sync..."
rsync --archive "$SRC" "$DST"
while [ "1" ]; do
rsync --itemize-changes --archive "$SRC" "$DST"
sleep $PAUSE
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.