1、安装WLS

主要参考Windows10上使用Linux子系统(WSL)这篇文章进行安装,不要通过lxrun /install /y去安装,这种方法安装貌似没有wsl命令。

先把win 10 版本升级到16215.0以上,否则在Microsoft Store里的所有Linux都会显示免费下载为不可点击,升级win 10参考Download Windows 10即可。

如在Microsoft Store里选择Ubuntu,安装完启动并设置用户密码便可使用。

Installing, this may take a few minutes...
Please create a default UNIX user account. The username does not need to match your Windows username.
For more information visit: https://aka.ms/wslusers
Enter new UNIX username: sandwich
Enter new UNIX password:
Retype new UNIX password:
passwd: password updated successfully
Installation successful!

2、rsync

配置rsync,/home/sandwich/rsyncd/rsyncd.conf中加入以下内容:

log file = /home/sandwich/rsyncd/rsyncd.log
port = 8730
use chroot = false
read only = false

[WINDOWS_PROJECT_RSYNC_PATH]
path = /home/sandwich/rsyncd/dest

通过以下命令即可启动rsync

rsync --daemon --config=/home/sandwich/rsyncd/rsyncd.conf --no-detach

测试rsync同步

C:\Users\sandwich>wsl rsync --port=8730  -rlptDvzHS --progress --delete /home/sandwich/rsyncd/source/ sandwich@127.0.0.1::WINDOWS_PROJECT_RSYNC_PATH
sending incremental file list
./
a.txt
              5 100%    0.00kB/s    0:00:00 (xfr#1, to-chk=0/2)

sent 118 bytes  received 42 bytes  320.00 bytes/sec
total size is 5  speedup is 0.03

3、脚本修改

删除32位的python,参考windows下,python3.6 32位、64位共存及开发工具vscode配置安装python 64位,32位无法通过shell_command调用wsl。

重新MySQL-python参考Windows 10安装Python 2.7和MySQL-python

添加方法rsyncFiles用于同步,替换原来的copyFiles方法:

def rsyncFiles(source, target):
    source_path = WSL_PROJECT_RSYNC_PATH + source + "/"
    target_path = "sandwich@127.0.0.1::" + WINDOWS_PROJECT_RSYNC_PATH + target
    shell_command("wsl rsync --port=8730  -rlptDvzHS --progress --delete " + source_path + " " + target_path)

4. 参考

Windows10上使用Linux子系统(WSL)

rsync-server-using-windows-subsystem-for-linux

Download Windows 10

手把手windows64位配置安装python2.7

[python subprocess.call() cannot find Windows Bash.exe](https://stackoverflow.com/questions/39812882/python-subprocess-call-cannot-find-windows-bash-exe)

Windows and Ubuntu Interoperability

Windows 10安装Python 2.7和MySQL-python

windows下,python3.6 32位、64位共存及开发工具vscode配置

解决"pip Fatal error in launcher: Unable to create process using ... "的错误

升级pip后不能运行的解决办法

win10更新出错0x80070422的解决方案

win10怎么更新到1709版本