This is a great tip as rsync is super fast and can work both ways. But rsync is too good just to be a *nix only utility. There is also a Windows version available from ITeF!x that installs cygwin, ssh and all the other goodies to get you going on the Windows side. Follow the installation instructions and you shouldn't have any problems. To make life easy I added the default install directory (C:\Program Files\cwRsync\bin) to my path. I also added a couple of system variables for cygwin: CYGWIN = nontsec and HOME = c:\path\to\home\directory. Once you have rsync downloaded an installed you can alter the code above slightly to work on a Windows system.desc "Deploy basic application directories" task :deploy => :environment do dirs = %w{ app lib test public/images public/stylesheets public/javascripts db} dirs.each do | dir| onserver = "username@yourdomain.com:/home/username/web/" local = "/cygdrive/c/rails_app/" + dir cmd = "rsync -arvz -e ssh #{local} #{onserver} --exclude \"*.svn*\" --exclude \"*~\" " puts cmd rsync = IO.popen(cmd, "r") while line = rsync.gets end rsync.close endend
Notice that in the local assignment I'm not using "#{RAILS_ROOT}/". This is because of the way cygwin has to access the NT (or FAT I suppose) file system. "/cygdrive/c/rails_app/" evaluates to "c:\rails_app". Notice also that I added another exclude for files ending with ~. This is because I use VIM and it leaves these files all over and I haven't gotten around to another solution but this should serve as an example of how to exclude other file types.Once last piece of goodness. If you're using Textdrive (and why wouldn't you?) then you can set up certificates to authenticate with rsync instead of a password. Here's how it works. Open a command prompt. If you've added C:\Program Files\cwRsync\bin to the path then the ssh command should be available from the command line. Type this:ssh-keygen -dYou will be prompted to save the key to a file. Choose a location otherwise it will default to the value in your $HOME + \id_dsa. When prompted for a passphrase you can leave it blank.Now upload the *.pub file you just created to Textdrive into your /home/username/.ssh directory and rename it to authorized_keys if this file doesn't exist otherwise copy the contents of your file into the end of the authorized_keys file. Once this is done you know have a way to authenticate yourself via certificate from your machine to the Textdrive server. This means that when you run the "rake deploy" command you won't be prompted for a password each time because you are authenticating via public/private keys.