Windowsでrsyncを使いたい

2018/10/27

Windows環境でrsyncを使おうとすると最初に見つかる選択肢は cwRsync です。cwRsyncはrsyncを動作させるためにCygwinやら何やらをパッケージングしたソフトウェア。

ググると「フリーで使えるよ」的な記事がたくさん見つかるんですが、公式サイトを探しても見当たりません。調べてみたら Wikipedia

As of August 2018 the free version of cwRsync is discontinued and the last free version 5.7.2 is no longer directly available from Itefix.

という記載を発見。あらま。有料版だけになっちゃったんですね。

こういうときは変にトリッキーなことをせず、おとなしくWindows Subsystem for Linux(WSL)を使うに限ります。Ubuntuだとインストール済み。

root@backport:~$ which rsync
/usr/bin/rsync
root@backport:~$

そして、WSLはコマンドプロンプトから直接呼び出すことができます。wslのあとに呼び出したいコマンドを続ければOK。たとえばこんな感じ。

F:\> wsl uname -a
Linux backport 4.4.0-17134-Microsoft #345-Microsoft Wed Sep 19 17:47:00 PST 2018 x86_64 x86_64 x86_64 GNU/Linux
F:\>wsl pwd
/mnt/f

F:\>

同じようにrsyncも呼び出せます。

F:\> wsl 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, 64-bit timestamps, 64-bit long ints,
    socketpairs, hardlinks, symlinks, IPv6, batchfiles, inplace,
    append, ACLs, xattrs, iconv, symtimes, prealloc

rsync comes with ABSOLUTELY NO WARRANTY.  This is free software, and you
are welcome to redistribute it under certain conditions.  See the GNU
General Public Licence for details.

F:\>

これでWindows(しかもコマンドプロンプト)からrsyncを呼び出せるようになりました。

まあ、全部WSL上で作業すればいい話ではあるんですが、日常のこまごました処理をバッチファイルでやっているのでコマンドプロンプトを捨てるわけにも行かないんですよね。コマンドプロンプトとWSLが透過的に扱えるのはありがたい限りです。

参考URL




おススメ