Rake task for rsync deployment and rails wiki


I’ve looked around the net today for the nicely integrated into rails
for rsync-based deployment but failed to find anything good enough so
just moved on and create my own rake task. It allows to deploy
to a number of different servers configured in config/rsync.yml file and
supports exclusions listed as the plain text file in
Iniatilly I wanted to share this thing on rails’ wiki but the current
related to the same tasks seems to have some problems and previous posts
this maillist suggests that wiki doesn’t feel itself good nowdays
because of
all the spam.

So if anyone is interested in this code - I can post it here in the
with relevant description. Does anyone need it?

WBR, Oleg Ivanov
ICQ #69991809
Jabber: [email protected]

I don’t need it, but I’m sure that at some point there will definitely
be someone who searches this mailing list for something like this! You
should post it :wink: Good work, and thanks!

-Ben L.

Ok, so attached is the rake file that should be saved in the lib/tasks/
as usual. It provides a new rake task called “sync” that synchronizes
application’s RAILS_ROOT with the specified directory on remote server.
uses rsync running over ssh remote shell transport.

To use this task you should first define the parameters of a remote
servers in
config/rsync.yml file. Let’s see an example:

default_target: production

host: test.server.net
port: 22
user: tester
dir: /home/tester/railsapp

host: google.com
user: root
dir: /etc

In the first line default_target defines a default sync target that will
used if no explicit target is given on the command line.
Then all required servers are listed under their nicknames in the shown
format. Parameters host, user and dir are required and port is optional.

To run the task in the dry-run mode without actually forcing any changes
the remote server do:
% rake sync
It will give you back the rsync’s log. If you are sure that everything
is fine
and you want to actually deploy your app do:
% rake sync go=
and every time you need to roll out your changes on the server - just
type “rake sync go=” again and you’re done.

In this form task uses default target set in your config file. If you
want to
deploy to any other server from you configuration add the argument “to”:
% rake sync to=test go=
Of course, you can skip “go” arg and do a dry run:
% rake sync to=test

And the last thing - if you don’t want some of your local directories to
synchronized (log, tmp, etc) you can list them in the
config/rsync_exclude.txt file.
The sample rsync_exclude.txt looks like:


Hope that will be helpful to someone, ask me if you have any
problems/suggestions relates to this thing.

PS: this task was hugely inspired by the similar task from Symfony PHP
framework though improved a bit by me to be more convenient.

WBR, Oleg Ivanov
ICQ #69991809
Jabber: [email protected]


I was interested in looking at the rake task referred to in this post,
but never could find it.

I know this is an old topic, but if anyone else caught it, I’d
appreciate it if you could forward or repost.