Skip to content

Instantly share code, notes, and snippets.

@fritz-c
Last active February 26, 2016 06:17
Show Gist options
  • Save fritz-c/6f18ad6d2eb90fdea188 to your computer and use it in GitHub Desktop.
Save fritz-c/6f18ad6d2eb90fdea188 to your computer and use it in GitHub Desktop.
Upload all changed and new files in git to multiple servers using rsync
#!/usr/bin/env bash
#
# Push changed files to dev server
#
# License: MIT
LOCAL_BASE="/path/to/local/dir"
REMOTE_BASE="/path/to/remote/dir"
SERVER_ALIASES=("dev" "dev2" "dev3")
cd "$LOCAL_BASE" || exit
printf "Sending"
# Move files to server
for serverAlias in "${SERVER_ALIASES[@]}" ; do
printf "."
git status --porcelain | egrep -v "^ D" | cut -c4- | rsync -rRq --files-from=- ./ "$serverAlias":"$REMOTE_BASE" || { echo "$serverAlias upload failed" ; exit 1; }
done
printf "done!\n"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment