basic deployment script using rsync
Here is a simple rsync script that you can use to deploy/provision/baseline any webapp with
#!/usr/bin/env sh
user_name=devuser
export user_name
private_key=config/id_dsa
export private_key
remote_host=192.168.3.111
export remote_host
local_path=./
export local_path
remote_path=/var/www/vhosts/usmagazine
export remote_path
exclude_file=config/rsync_exclude.txt
export exclude_file
# -e in the rsync command forces rysnc to use ssh as the transport protocol and then
# it passes -ax to the ssh command to disable interactive shell and x11 on the server
# -C in the rsync command causes rsync to ignore the subversion and cvs folders in the
# directory tree
# -a in the rysnc command puts rsync in archive mode recursing all folders and
# preserving users symlinks permissions and timestamps
# -z turns on rsync compression
# --delete will delete any files from the remote file system that don't exist on the
# local file system
# --force forcibly answers yes to any prompts for confirmation from rsync
# --exclude-from passes in a file that contains patterns (1 per line) that match files
# using rsync's pattern matching syntax (* for wildcard etc.) a line preceded with a +
# tells rsync to include any files matching the pattern and a line preceded by - tells
# rsync to ignore files matching the pattern. By default all files are included so
# most times you only have to make patterns to black list certain files (for instance
# configuration files that are specific to your sandbox and that should not be
# transferred to a production server)
rsync --progress -azC --force --delete --exclude-from=$exclude_file -e "ssh -ax -i $private_key" $local_path $user_name