Skip to content

Instantly share code, notes, and snippets.

@sseidenthal
Created December 23, 2016 21:43
Show Gist options
  • Save sseidenthal/3b3975dd3f2c5d10ffbdb6ede6010b73 to your computer and use it in GitHub Desktop.
Save sseidenthal/3b3975dd3f2c5d10ffbdb6ede6010b73 to your computer and use it in GitHub Desktop.
#!/bin/bash
while getopts h:u:s:d: option
do
case "${option}"
in
h) HOST=${OPTARG};;
u) USER=${OPTARG};;
s) SOURCE=${OPTARG};;
d) DESTINATION=$OPTARG;;
esac
done
function check_exit_code {
"$@"
local status=$?
if [ $status -ne 0 ]; then
echo "sync failed"
afplay /System/Library/Sounds/Basso.aiff
else
echo "sync ok"
fi
}
function check_params {
error=false
if [ -z "$USER" ]; then
error=true
echo "- USER missing"
fi
if [ -z "$HOST" ]; then
error=true
echo "- HOST missing"
fi
if [ -z "$SOURCE" ]; then
error=true
echo "- SOURCE missing"
fi
if [ -z "$DESTINATION" ]; then
error=true
echo "- DESTINATION missing"
fi
if [ "$error" = true ] ; then
afplay /System/Library/Sounds/Basso.aiff
exit
fi
}
check_params
check_exit_code rsync -u -h -v -c -r -z -l -e ssh --exclude 'mysql_dumps' --exclude='.git' --exclude '.gitignore' --exclude='.idea' --exclude 'web/bundles' --exclude='vendor' --exclude='app/cache' --exclude='app/logs' --exclude='web/temp/xml' --exclude='web/dynamic' $SOURCE $USER@$HOST:$DESTINATION
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment