Skip to content

Instantly share code, notes, and snippets.

@pgorczak
Last active October 9, 2018 15:39
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save pgorczak/c2f70e603e4edff0115542508af971cb to your computer and use it in GitHub Desktop.
Save pgorczak/c2f70e603e4edff0115542508af971cb to your computer and use it in GitHub Desktop.
Simplest script that auto-syncs a folder to a remote destination
#!/bin/bash
# Args: source destination
# Needs rsync and inotify-tools
# Hidden files and folders are excluded via regex (inotifywait) and patterns (rsync)
while true; do
rsync -avz --exclude ".*" --exclude ".*/" $1 $2
inotifywait -r -e modify,attrib,close_write,move,create,delete --exclude="\/\." $1
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment