Rsync on Windows

1,378 views
Skip to first unread message

Ian Anderson Gray

unread,
Apr 25, 2014, 7:18:06 AM4/25/14
to vagra...@googlegroups.com
Hi.
For some reason my last didn't post, so trying again...
I'm very new to Vagrant and I am no sys admin. I'm hoping to use it to develop WordPress sites. I am currently using Chris Wiegman's Primary Vagrant which is working very well. Except when I start to add the files for my theme it starts to run VERY slowly. After a bit of research it might have something to do with synched files as that can slow things down.

My host OS is Windows 8 64 bit
My guest OS is Ubuntu

After Googling I found out that the latest Vagrant versions offer a work around with rsync. This blog post states: 

As long as rsync is installed in both the host and the guest, this will just work. Since rsync is a standard utility for Mac and most Linux distributions, this just works most of the time! For Windows users, msysgit, MinGW, and Cygwin all provide rsync.

That leaves me scratching my head- what do I need to do to get this working? Currently I am using the command line shell from GitHub (uses Powershell) and I'd prefer to continue using that. I've installed Git for Windows and Cygwin but they require me to use different command line environments. As you can probably tell I don't really understand- but I want to get this sorted.

Once I've got that sorted, I assume I just need to add  type: "rsync", rsync__exclude: ".git/" to the synced folder lines in my Vagrant file:

config.vm.synced_folder "sites/stable.wordpress.vagrant", "/var/www/stable.wordpress.vagrant", :owner => "www-data", :mount_options => [ "dmode=775", "fmode=774" ], type: "rsync", rsync__exclude: ".git/"
config.vm.synced_folder "sites/stable.wordpress.vagrant/uploads", "/var/www/stable.wordpress.vagrant/wordpress/wp-content/uploads", :owner => "www-data", :mount_options => [ "dmode=775", "fmode=774" ], type: "rsync", rsync__exclude: ".git/"
config.vm.synced_folder "sites/trunk.wordpress.vagrant", "/var/www/trunk.wordpress.vagrant", :owner => "www-data", :mount_options => [ "dmode=775", "fmode=774" ]type: "rsync", rsync__exclude: ".git/"

Is that correct?

I love Vagrant, but it does require a lot of technical knowledge- particularly for those of us who don't have a lot of server experience. Has anyone got any experience in getting rsync working on Windows?

Thanks!


Ian Anderson Gray

unread,
Apr 28, 2014, 5:00:53 AM4/28/14
to vagra...@googlegroups.com
I'm not sure how many Windows users there are in this group, but I thought I'd give a quick update...

I managed to get rsync on Windows by installing cwRsync. I installed the free version using the instructions here - http://www.rsync.net/resources/howto/windows_rsync.html

That didn't work, but after Googling I found an answer to a similar question. It had to do with adding the path to the environmental variables so rsync could be accessed from all folders:
http://stackoverflow.com/questions/20493309/cwrsync-in-windows-not-being-recognised

Unfortunately I am still getting errors with I do vagrant up. I really don't understand what the problem is. I know there were issues with previous versions of Vagrant, but I am on the latest one (v1.5.4)

Here are the error messages:

==> default: Rsyncing folder: /cygdrive/c/Users/IanAnderson/Documents/Sites/Vagrants/Primary-Vagrant/vagrant-local/sites
/stable.wordpress.vagrant/ => /var/www/stable.wordpress.vagrant
==> default:   - Exclude: [".vagrant/", ".git/"]
There was an error when attempting to rsync a synced folder.
Please inspect the error message below for more info.

Host path: /cygdrive/c/Users/IanAnderson/Documents/Sites/Vagrants/Primary-Vagrant/vagrant-local/sites/stable.wordpress.v
agrant/
Guest path: /var/www/stable.wordpress.vagrant
Command: rsync --verbose --archive --delete -z --chmod=ugo=rwX --no-perms -e ssh -p 2222 -o StrictHostKeyChecking=no -i
'C:/Users/IanAnderson/.vagrant.d/insecure_private_key' --exclude .vagrant/ --exclude .git/ /cygdrive/c/Users/IanAnderson
/Documents/Sites/Vagrants/Primary-Vagrant/vagrant-local/sites/stable.wordpress.vagrant/ vag...@127.0.0.1:/var/www/stabl
e.wordpress.vagrant
Error: Warning: Permanently added '[127.0.0.1]:2222' (RSA) to the list of known hosts.
rsync: connection unexpectedly closed (0 bytes received so far) [Receiver]
rsync error: error in rsync protocol data stream (code 12) at io.c(605) [Receiver=3.0.9]
rsync: read error: Connection reset by peer (104)
rsync error: error in rsync protocol data stream (code 12) at io.c(759) [sender=3.0.6]

Alvaro Miranda Aguilera

unread,
Apr 28, 2014, 6:37:43 AM4/28/14
to vagra...@googlegroups.com
usually those rsync came with an ssh utility , and you should use it as

rsync -e 'path/to/ssh'

try to use the rsync from command line and test

i havent used the rsync sync from vagrant but as command line rsync i use this one

take note it require to use the ssh that came in the same software, in case you have more than one ssh in the path/ prompt..

Alvaro.


--
You received this message because you are subscribed to the Google Groups "Vagrant" group.
To unsubscribe from this group and stop receiving emails from it, send an email to vagrant-up+...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Ian Anderson Gray

unread,
Apr 28, 2014, 10:44:42 AM4/28/14
to vagra...@googlegroups.com
Are you referring to the guest OS or the host? I know the the guest (Ubuntu) has the ssh utility installed. Not sure about Windows.

Unfortunately I don't really understand what I should be doing. Are you saying I need to configure rsync on Windows more? Or do I need to do something in my Vagrant file.

It's been a very frustrating journey trying to get Vagrant running on Windows, but I hope I can eventually get there. Thanks for your help.

Ian

Alvaro Miranda Aguilera

unread,
Apr 28, 2014, 9:21:36 PM4/28/14
to vagra...@googlegroups.com
Ah, assumptions, the mother of all the problems, I did assume you will understand.

:)

Let me go back one step.

rsync,

rsync is a tool that can be used local or remote. for local, you use rsync source destination, done

for remote, you have 2 options

rsync.remote.1 Use an rsync daemon, quite fast, etc, but requirees a daemon port, so most people go to method 2.
rsync.remote.2 use SSH to encapsulate rsync traffic.

Lets' talk about rsync remote using ssh.

this is a client server thing, so, it require, on host and destination have rsync installed.
in order to use rsync over ssh, requires ssh server running on destination, ssh client on host.

put this into your setup, you have.

Physical host, windows
require ssh binary
require rsync binary

Guest host, linux
require ssh server running
require rsync binary


Let's clear out all the assumptions out,
If you can connect to the guest with vagrant ssh or ssh localhost -p <port that vagrant tells you, say 2222>
you have the ssh part running on the guest
once connected to the guest, do which rsync, if you see an rsync command, then the guest requirement are set


Back to your host, and now I will not make assumptions.

From Vagrant manual:


"As long as rsync is installed in both the host and the guest, this will just work. Since rsync is a standard utility for Mac and most Linux distributions, this just works most of the time! For Windows users, msysgit, MinGW, and Cygwin all provide rsync."


On your windows machine, if you want to use rsync, be sure, both rsync and ssh (from the same distribution you used to get rsync), are available from the path.

Test it.

vagrant up
vagrant ssh-config

ssh -p <port> vagrant@localhost

if you see a prompt and you get asked by password, then ssh is working

Not, test rsync

rsync -e 'ssh -p <port>' vagrant@localhost

same, if you see the prompt, is most likely it's working

Now you can test vagrant rsync and *should* work

test from command line to any linux/unix box you have with a valid user password to ensure both ssh and rsync works

hope this clarify better.

Alvaro.,

Ian Anderson Gray

unread,
Apr 30, 2014, 10:38:28 AM4/30/14
to vagra...@googlegroups.com
Thanks so much, Alvaro! You're almost getting the right level for me! :-)

I'm not quite there yet, but I am systemically going through all that you wrote and it seems to be working. I just want to get my head round everything you said fully and get it working as best as I can and then I'll let you know how I have got on.

I assume I do have to set the synched folders in the Vagrant file to use rsync as I originally mentioned? Will I need to run the vagrant rsync command at all, or will it be automatic? Still a little confused there.

Thanks.

Ian Anderson Gray

unread,
Apr 30, 2014, 11:45:59 AM4/30/14
to vagra...@googlegroups.com
Hmmm,

I'm still encountering some issues.

I do have rsync installed on the host and guest machines.

I can connect to my guest machine- vagrant ssh works fine.

I then did the following:
vagrant up
vagrant ssh-config

I then see the following:

Host default
  HostName 127.0.0.1
  User vagrant
  Port 2222
  UserKnownHostsFile /dev/null
  StrictHostKeyChecking no
  PasswordAuthentication no
  IdentityFile C:/Users/IanAnderson/.vagrant.d/insecure_private_key
  IdentitiesOnly yes
  LogLevel FATAL
  ForwardAgent yes

Since the port is 2222, I then did:

ssh -p <port> vagrant@localhost

I then get prompted for the password like this:

Warning: Permanently added '[localhost]:2222' (RSA) to the list of known hosts.
vagrant@localhost's password:

I wasn't sure what password I was supposed to put in there, but the password vagrant seems to work.

You then say use this command: "rsync -e 'ssh -p <port>' vagrant@localhost"
I assume this is again from the Windows command prompt. I get the following error message:

rsync: link_stat "/cygdrive/c/Users/IanAnderson/Documents/Sites/Vagrants/Primary-Vagrant/vagrant@localhost" failed: No s
uch file or directory (2)
rsync error: some files/attrs were not transferred (see previous errors) (code 23) at main.c(1039) [sender=3.0.6]


Any thoughts?

Alvaro Miranda Aguilera

unread,
Apr 30, 2014, 5:39:23 PM4/30/14
to vagra...@googlegroups.com
you didn't include the command you used.. so I don't now what you typed.


but rsync require 2 extra parameters (which i assumde you will know.. haha, sorry)

source and destination!

so try this

rsync -e 'ssh -p 2222'   file  vagrant@localhost:/tmp

where file is any file




--

Fabian Schmengler

unread,
May 21, 2014, 3:31:11 AM5/21/14
to vagra...@googlegroups.com
I had the same problem with exactly these error messages when I tried to use msysgit with rsync.exe from DeltaCopy. In the end I switched to Cygwin, there it worked immediately.

  1. Install Cygwin: http://cygwin.com/install.html
  2. When asked for packages to install, choose "rsync" and "openssh"
  3. Open the Cygwin terminal and type
    1. cd /cygdrive/c/Users/IanAnderson/Documents/Sites/Vagrants/Primary-Vagrant/
    2. vagrant up

HTH

jack reacher

unread,
Nov 30, 2017, 3:35:01 PM11/30/17
to Vagrant

jack reacher

unread,
Nov 30, 2017, 3:35:24 PM11/30/17
to Vagrant

Baretto James

unread,
Dec 11, 2017, 1:56:12 PM12/11/17
to Vagrant
I too dont had much server experience, my friend told me to use GS Richcopy 360, this software guides you through the whole process and is GUI based so you dont have to remember any commands. Just google this software, its by guru squad, it will surely help you. Helped me too!


On Friday, April 25, 2014 at 4:48:06 PM UTC+5:30, Ian Anderson Gray wrote:
Reply all
Reply to author
Forward
0 new messages