Last active
February 26, 2016 06:17
-
-
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
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 | |
# | |
# 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