3 _ProdServers=" app1-1 app1-2 app2-1 app2-2 app3-1 app3-2 stanns bibc-prod"
9 ./deployfile.sh -f filename -p /path/to/destination/ [ -u remoteuser ] [ -b ] host1 [ host2 ... ]
12 -f Name of file to be deployed
13 -p Path on remote server where file should be deployed to
14 -u Username to use when logging into remote server; if not provided, defaults to current user
15 -b Backup flag (optional); creates a backup instead of overwriting file on remote server
16 -h Print this message and exit
17 -P auto add all production machines to host list
21 while getopts ":f:p:u:bPh" opt
27 b ) BACKUP="-b --suffix=.`date +%Y%m%d%H%M`";;
32 shift $(($OPTIND - 1))
34 if [[ -z "$FILE" ]] || [[ -z "$DEST" ]] | ([[ $# -lt 1 ]] && [[ -z "$PROD" ]])
51 echo "adding ${_ProdServers} to hosts"
52 _hosts="$@$_ProdServers"
57 RSYNC_DEST="${HOST}:${DEST}"
58 #echo -e "$HOST:\n\tFILE=$FILE\n\tDEST=$DEST\n\tUSER=$USER\n\tBACKUP=$BACKUP\n\tSSH=$SSH\n\tRSYNC_DEST=$RSYNC_DEST\n"
59 rsync -e"${SSH}" $BACKUP -avz $FILE $RSYNC_DEST