Created
May 8, 2020 13:03
-
-
Save eduo/b415217fa1f911f70e38442ab899502c to your computer and use it in GitHub Desktop.
OSX Bash Script to synchronise remote folder when changes are detected. Requires fswatch (homebrew)
This file contains 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 | |
# | |
run_rsync_acc () { | |
RSYNC_COMMAND=$(rsync -azPim --delete-before --no-motd --exclude ".*/" --exclude=.DS_Store ~/rootfolder/ remoteuser@remotesite.com:remotelocation) | |
if [ $? -eq 0 ]; then | |
# Success do some more work! | |
if [ -n "${RSYNC_COMMAND}" ]; then | |
# Stuff to run, because rsync has changes | |
echo "Sincronized: " | |
# echo $? | |
# osascript -e 'display notification "Updated remote" sound name "Tink"' | |
osascript -e 'display notification "Updated remote"' | |
# else | |
#echo "NO changes" | |
# No changes were made by rsync | |
fi | |
else | |
# Something went wrong! | |
echo "Error! Something went wrong!" | |
exit 1 | |
fi | |
} | |
run_rsync_acc | |
fswatch -o ~eduo/rootfolder | while read f | |
do date | |
run_rsync_acc | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment