Skip to content

Instantly share code, notes, and snippets.

@wellic
Created March 19, 2015 08:18
Show Gist options
  • Save wellic/3e9f3d45bb15a2613f42 to your computer and use it in GitHub Desktop.
Save wellic/3e9f3d45bb15a2613f42 to your computer and use it in GitHub Desktop.
small rsync tools
#!/usr/bin/env bash
set -e
DEBUG=1
DST=your_destination_path
SRC=$(dirname "$0")
declare -a EXCLUDE=(
/.git/
/web/assets/*
sync.sh
)
STARTDIR=$PWD
cd "$SRC"
SRC=$PWD
OPT_EXCLUDE=''
for f in "${EXCLUDE[@]}"; do
OPT_EXCLUDE="$OPT_EXCLUDE --exclude=$f"
done
OPT='-zavP --delete'
[ "$DEBUG" != '0' ] && OPT="-ni $OPT" || :
CMD=$(echo rsync "$OPT" "$OPT_EXCLUDE" "$SRC"/ "$DST")
echo $CMD
$CMD
cd "$STARTDIR"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment