Created
March 19, 2015 08:18
-
-
Save wellic/3e9f3d45bb15a2613f42 to your computer and use it in GitHub Desktop.
small rsync tools
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
#!/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