The capistrano_rsync_with_remote_cache gem has been merged into the viget_deployment Rails plugin: http://svn.extendviget.com/lab/trunk/plugins/viget_deployment The Rails plugin includes a Rakefile that will build a capistrano_rsync_with_remote_cache gem which can be used independently of Rails.
Capistrano rsync_with_remote_cache
A deployment strategy for Capistrano which combines rsync with a remote cache, allowing fast deployments from Subversion repositories behind firewalls.
This gem was extracted from the VlCapistrano gem to allow easy use without the other, somewhat more esoteric features of VL Capistrano.
Requirements
This gem requires Capistrano 2.0.0 and higher. Git support requires Capistrano 2.1.0 or higher.
This gem has only been tested with Subversion and Git. It is unlikely to be supported for other SCM systems unless we adopt them at Viget Labs, or get outside help.
This gem requires and rsync command line utilities on the local and remote hosts. It also requires either svn or git on the local host, but not the remote host.
This gem is tested primarily on Mac OS X and Linux. It may work with a Windows local host, but is not tested or supported. Like Capistrano itself, it will not work with a Windows remote host.
Gem preliminaries
To create the gem, run rake package in this directory, which will dump the gem in the pkg subdirectory.
To use this deployment strategy, add this line to your configuration:
set :deploy_via, :rsync_with_remote_cache
How it works
This strategy maintains two cache directories:
- The local cache directory is a checkout from the SCM repository. The local cache directory is specified with the local_cache variable in the configuration. If not specified, it will default to ".rsync_cache" in the same directory as the Capfile.
- The remote cache directory is an rsync copy of the local cache directory. The remote cache directory is specified with the repository_cache variable in the configuration (this name comes from the remote_cache strategy that ships with Capistrano, and has been maintained for compatibility.) If not specified, it will default to "shared/cached-copy" (again, for compatibility with remote_cache.)
Deployment happens in three major steps. First, the local cache directory is processed. If it does not exist, it is created with a checkout of the revision to be deployed. If it exists, it is updated to the revision to be deployed.
Second, rsync runs on the local side to sync the remote cache to the local cache. When the rsync is complete, the remote cache should be an exact replica of the local cache.
Finally, a copy of the remote cache is made in the appropriate release directory. The end result is the same as if the code had been checked out directly on the remote server, as in the default strategy.
Tweaking rsync
By default, the options used to the rsync command in the second step are -az --delete. As of version 2.1, the rsync_options configuration variable can be used to change these options. For instance, using -az --delete --exclude=.svn --delete-excluded would avoid copying the SVN metadata directories to the server. Careful: this variable replaces the default; it does not add to it! If you don't include at least -a you'll likely not get anything done.
