Rsync Deploy and Windows 10


#1

HI,
I am trying to deploy my site with Rsync as described in the Deployment with Rsync docs.
Using the same script as described the site is correctly built (I guess so since the public directory has been created) but at the deployment phase I got the following error:
./deploy: line 6: rsync: command not found
I use Git for Windows and I dont know how to get Rsync working (or installed for Windows 10 as well)
Any help would be very much appreciated !


#2

rsync acts as a client/server over ssh. It’s not a part of git for Windows or otherwise.

EDIT: in other words, you need an ssh client and rsync on your machine and server. I’m not aware of any good clients for Windows.

However, most people use git to deploy, using a bare backing repository with a post-receive hook to checkout a working directory in your webroot… or a hosting service which takes care of this automatically.


#3

Yeah, search for rsync windows and find out the cmd line equivalent.

Alternatives exist: http://acrosync.com/windows.html

If you get it working, please post the resulting deploy batch so others can benefit.


#4

If you like the command line (cli), here are 2 other options - if you are on windows 10:

Windows Subsystem for Linux


(I tested ubuntu)

you will end up in an ubuntu system (no gui), which you will have to
update yourself.
ssh, rsync are included.

cmder + git-for-windows + rsync

1)

http://cmder.net/ (Download Full)
=> console + git-for-windows

(I extracted to C:\Apps\cmder)

2)

review:
https://blog.tiger-workshop.com/add-rsync-to-git-bash-for-windows/

If you are OK with it - I had to download
http://repo.msys2.org/msys/i686/rsync-3.1.2-2-i686.pkg.tar.xz
not
http://repo.msys2.org/msys/x86_64/rsync-3.1.2-2-x86_64.pkg.tar.xz

You need 7zip in order to extract (twice)
rsync-3.1.2-2-i686.pkg.tar.xz
=> rsync-3.1.2-2-i686.pkg.tar
=> rsync-3.1.2-2-i686.pkg

You get:

└── usr
    ├── bin
    │   └── rsync.exe
    ├── lib
    │   └── rsync
    │       └── rrsync
    └── share
        └── man
            ├── man1
            │   └── rsync.1.gz
            └── man5
                └── rsyncd.conf.5.gz

Copy usr/bin/rsync.exe to your vendor git usr dir:
C:\Apps\cmder\vendor\git-for-windows\usr

Now you are in.

Here’s a demo. $ prompt is windows cmder shell

ssh keys

$ echo %HOME%
C:\Data\home

$ ls C:\Data\home\.ssh
id_dsa
id_dsa.keystore
id_dsa.pub
known_hosts

versions

$ git version
git version 2.11.0.windows.1
$ which rsync
/usr/bin/rsync
$ rsync --version
rsync  version 3.1.2  protocol version 31
Copyright (C) 1996-2015 by Andrew Tridgell, Wayne Davison, and others.
Web site: http://rsync.samba.org/
Capabilities:
    64-bit files, 64-bit inums, 32-bit timestamps, 64-bit long ints,
    socketpairs, hardlinks, symlinks, IPv6, batchfiles, inplace,
    append, ACLs, no xattrs, iconv, symtimes, prealloc

prepare new directory on linux host

# zama1 is a linux host (IP in my etc/hosts)

$ ssh root@zama1
Enter passphrase for key '/c/Data/home/.ssh/id_rsa':

Debian GNU/Linux comes with ABSOLUTELY NO WARRANTY, to the extent
permitted by applicable law.
Last login: Mon Jan 22 21:09:25 2018 from ~~~ cut

# group sticky bit is set!
# was: chmod g+s /srv/www/
root@zama1: # ls -ld /srv/www/
drwxr-sr-x 19 www-data www-data 4096 Jan 22 21:14 /srv/www/


root@zama1:~# mkdir /srv/www/test
# user www1 must exist
root@zama1:~# chown www1:www-data /srv/www/test
root@zama1:~# exit
logout
Connection to zama1 closed.

using rsync in git-for-windows (cmder shell)

I’m in a directory with a public directroy:

$ rsync -rlt -v --groupmap=*:www-data  public/ www1@zama1:/srv/www/test
Enter passphrase for key '/c/Data/home/.ssh/id_rsa':
sending incremental file list
./
404.html
index.html
...

sent 14,749,142 bytes  received 11,719 bytes  797,884.38 bytes/sec
total size is 14,707,588  speedup is 1.00

# change some files (run hugo)

$ rsync -rlt -v --groupmap=*:www-data  public/ www1@zama1:/srv/www/test
Enter passphrase for key '/c/Data/home/.ssh/id_rsa':
sending incremental file list
pages/showcase/gallery-01/
pages/showcase/gallery-01/index.html

sent 49,066 bytes  received 607 bytes  9,031.45 bytes/sec
total size is 14,740,024  speedup is 296.74

But keep in mind - with both options you are going to need/learn some linux know-how…


#5

@it-gro nice, I had heard rumors about that and wondered if it really works.


#6

Thank you,
but I haven’t managed to sync successfuly with the suggested method (so far). Still working on it.


#7

Have you thought about deploying with Wercker using rsync? I do this, and it is very easy.

I followed the werker tutorial, and then modified the wercker file to sync to vultr - https://gohugo.io/hosting-and-deployment/deployment-with-wercker/

I use Moss.sh for server management.

Here is my wercker file: https://gist.github.com/thewebmastercom/6b5d6984fd0515672567a02b38b3c224

(NB: update the settings for your hostname, and add keys in wercker)


#8

Windows is a problem.

Well, I tried again today.

As told in the instruction to make the deploy file executable,

#!/bin/sh
USER=my-user
HOST=my-server.com
DIR=my/directory/to/topologix.fr/   # might sometimes be empty!

hugo && rsync -avz --delete public/ ${USER}@${HOST}:~/${DIR}

exit 0

I saved the above scripts to deploy.cmd and put it under my hugo site, in parallel with config.toml.
When double-click the deploy.cmd, the window splashed and vanished.

What’s next? There are no files in the desired folder on the server.

As for the SSH issue, I used BitVise SSH which has key generator and management tool.


#9

Please don’t use dashes in your post markdown. The result is a huge font that is the equivalent of shouting.

If you want to emphasize a phrase simply use the bold button provided in the post toolbar.


#10

That’s what happens when you double click a script file in Windows. Run it from inside cmd.exe so you have a chance of seeing what’s in it.

I assume you can connect normally to that server via ssh, without errors?