Deploying website files

Deploying website files between servers is best done using rsync. What the program rsync does is check the files on one server against the files on another server. If it finds missing or changed files, it transfers the missing files or the changed part of a file to the target server. This limits bandwidth usage compared to manually uploading files.

The alternative way to transfer website files between servers is to use FTP. This is time consuming and very manual if you are only uploading the files that have been updated.

Before you do setup a script to transfer files, you should Create SSH keys first. Below is an example of my code that deploys files between servers.

# transfer files from dev server to live server rsync -rtv -e "/usr/bin/ssh -i /var/www/.ssh/id_dsa" --exclude=.svn* --exclude="configuration.php" /var/www/websites/crystalwebdesigns.com.au/* username@marcwatts.com.au:public_html # transfer files from live server to dev server rsync -rtv -e "/usr/bin/ssh -i /var/www/.ssh/id_dsa" --exclude=.svn* --exclude="configuration.php" username@crystalwebdesigns.com.au:public_html/* /var/www/websites/marcwatts.com.au

By automatically deploying website files between servers you can save countless hours of manually labour and be sure all your files are up to date.