Rsync to Windows Open SSH

Attempting to perform an rsync operation from a Linux or macOS system to a Windows machine directly using the rsync command will fail. This is because Windows does not have a built-in rsync utility.

A typical command like rsync /source/ target-hostname:/mnt/e/target/ will result in an error.

Solution

Leverage the power of the Windows Subsystem for Linux (WSL) to enable rsync functionality on your Windows system.

Prerequisites

  • Enable OpenSSH Feature on Windows:
    • Open Windows Features (search for it in the Start menu).
    • Ensure the OpenSSH Server option is checked.
    • Restart your computer for the changes to take effect.

Steps

  1. Install WSL:

    • Open the Microsoft Store and search for “Windows Subsystem for Linux”.
    • Choose a distribution (e.g., Ubuntu) and install it.
  2. Install a Linux Distribution within WSL:

    • After installation, open a WSL terminal (e.g., Ubuntu).
    • Update the package list: sudo apt update
    • Install the rsync package: sudo apt install rsync
  3. Execute Rsync with WSL:

    • Modify your rsync command to include the wsl prefix for the rsync path:
    1
    
    rsync --rsync-path='wsl rsync' /source/ target-hostname:/mnt/e/target/
    • Replace /source/ with your local source directory.
    • Replace target-hostname with the hostname of your Windows machine.
    • Replace /mnt/e/target/ with the desired target directory on your Windows machine. The path should follow the Linux path format instead of the Windows format (E:\target).

Now, rsync should successfully transfer files between your Linux/macOS system and your Windows machine through WSL.

0%