deploy script
> Got a bit irritated with ftp/sftp last week so wrote a deploy bash
script so can upload site to server from terminal. It uses rsync to
transfer/update the files online over SSH seems a lot quicker and less
painful than trying to remember what files have changed or listing a
directory by date to find modified files. Will probably evolve this and
add it into each project as I work on them. I guess I could integrate
with tests so that it uploads if tests pass and possibly do some
compression of CSS files or Javascript files on upload. Not exactly
continuous build but hopefully a bit more automation in my day.
Caution: I've only tried this on my mac running OS X 10.5.8. Also if you don't configure the deploy_directory correctly you could overwrite/delete something important so its a potentially dangerous thing :)
I'm running the script from the root of the project i'm going to upload/sync.
Guess I'll improve this quite a bit over next few weeks as I use it for a few more sites, perhaps also work out a way of not getting prompted for the SSH password each time too. Perhaps though prompting might be a good thing.
Caution: I've only tried this on my mac running OS X 10.5.8. Also if you don't configure the deploy_directory correctly you could overwrite/delete something important so its a potentially dangerous thing :)
I'm running the script from the root of the project i'm going to upload/sync.
#!/bin/sh
# you could put the things to --exclude in a separate text file if they
# get to lengthy
#
application_name="shiny.thing";
deploy_server="example.com";
deploy_server_folder="example.com.folder/";
ssh_user="XXXXXX";
script_location="./";
echo "Deploying '$application_name' to '$deploy_server' in folder
'$deploy_server_folder'"
echo "Reading source $script_location"
rsync -avuz --delete --stats ./
$ssh_user@$deploy_server:$deploy_server_folder --exclude '.git'
--exclude 'sessions' --exclude 'deploy.sh' --exclude 'test.php'
--exclude '.DS_Store'
echo "Deployment successful and so much speedier than ftp/sftp"
Guess I'll improve this quite a bit over next few weeks as I use it for a few more sites, perhaps also work out a way of not getting prompted for the SSH password each time too. Perhaps though prompting might be a good thing.
/ Adam