Applies to: rsync 3.4.1 (Ubuntu 26.04) and 3.2.7 (Ubuntu 24.04) under WSL on Windows 10 version 2004 or later and Windows 11; cwRsync client 6.4.8 (rsync 3.4.1, OpenSSH 10.3p1)
Windows has no built-in rsync. The easiest way to get it is WSL (Windows Subsystem for Linux): install Ubuntu with wsl --install, run sudo apt install rsync inside it, and sync your Windows folder, which WSL shows under /mnt/c, to your server over SSH. If you cannot use WSL, cwRsync is a free Windows build of rsync that includes its own SSH client. Either way, rsync must also be installed on the Linux server, and it only sends files that changed since the last run.
Option 1: rsync through WSL (recommended)
- Install WSL. According to Microsoft, open PowerShell as administrator, run the command below and restart Windows. It installs Ubuntu by default; on first start you create a Linux user name and password.
wsl --install
If WSL is already installed,wsl --list --onlinelists the available distributions andwsl --install -d Ubuntuadds one. Our guide to running Linux on Windows with WSL covers the first steps. - Install rsync and the SSH client in the Ubuntu window:
sudo apt update sudo apt install rsync openssh-client rsync --version
In our lab this installedrsync version 3.4.1 protocol version 32on Ubuntu 26.04 and 3.2.7 on Ubuntu 24.04. - Find your Windows folder. WSL mounts drive C: at
/mnt/c, soC:\Users\me\siteis/mnt/c/Users/me/site. Put the path in quotes if it contains spaces. - Do a dry run first.
-nshows what would be copied without changing anything:rsync -avzn --chmod=D755,F644 /mnt/c/Users/me/site/ deploy@server.example.com:/var/www/example.com/
- Run the sync by repeating the command without
n:rsync -avz --chmod=D755,F644 /mnt/c/Users/me/site/ deploy@server.example.com:/var/www/example.com/
Lab output of the first and second run (Ubuntu 26.04, rsync 3.4.1; the SSH connection was replaced by a local stand-in because the lab runs no SSH server, the rsync output itself is real):
sending incremental file list index.html notes.txt css/ css/style.css sent 316 bytes received 85 bytes 802.00 bytes/sec total size is 24 speedup is 0.06 $ rsync -avz --chmod=D755,F644 ... (second run, nothing changed) sending incremental file list sent 148 bytes received 13 bytes 322.00 bytes/sec total size is 24 speedup is 0.15
The second run sent no files because nothing had changed. That is the main reason to use rsync instead of copying the whole folder each time.
Why the --chmod option matters
According to Microsoft, files on Windows drives have no Linux permissions by default, so WSL shows the same read, write and execute bits for user, group and others. In our lab, folders and files that show as rwxrwxrwx arrived on the server with mode 777 after a plain rsync -a. World-writable files on a web server are a security risk. With --chmod=D755,F644 the same upload gave 755 for folders and 644 for files. Use that option whenever you upload from /mnt/c.
Useful variations
- Trailing slash:
site/copies the contents of the folder;sitewithout the slash creates asitefolder inside the destination. - Mirror deletions: add
--deleteto remove files on the server that you deleted on Windows. Always try it with-nfirst; our dry run printeddeleting notes.txtbefore anything was removed. - Download from the server to Windows: swap source and destination:
rsync -avz deploy@server.example.com:/var/www/example.com/ /mnt/c/Users/me/backup/
Windows treatsFile.txtandfile.txtas the same name and Linux does not, so files whose names differ only in case can overwrite each other on the Windows side. - Other SSH port:
rsync -avz -e "ssh -p 2222" ..., see rsync with a non-standard SSH port. - SSH keys: inside WSL, rsync uses the Linux
sshand the keys in your WSL home folder (~/.ssh), not the ones inC:\Users\me\.ssh. Create or copy a key there for password-free syncs. - Skip folders such as
.gitornode_moduleswith--exclude; our article How to Exclude Files and Directories with rsync explains the patterns. - Speed: Microsoft notes that Linux tools work fastest on files stored in the WSL file system (
/home/you) rather than under/mnt/c. For large, frequent syncs, keep the working copy inside WSL.
Option 2: cwRsync (native Windows build)
cwRsync is published by itefix as a free "bare-bones Windows packaging" of rsync. The 6.4.8 x64 client we unpacked contained rsync.exe (rsync 3.4.1, built with Cygwin), ssh.exe (OpenSSH 10.3p1), ssh-keygen.exe and a template batch file, cwrsync.cmd. We did not run it on Windows; the rules below come from that batch file.
- Download the client from the itefix website and unzip it, for example to
C:\cwrsync. - Edit
cwrsync.cmdand put your rsync command at the end, where the file says "Enter your rsync command(s) here". The batch file adds itsbinfolder to the PATH so the DLLs are found. - Write Windows paths the Cygwin way:
C:\work\becomes/cygdrive/c/work/. Its own example is:rsync -r /cygdrive/c/work/ remotehost:/home/user/work/
- Add
-avz --chmod=D755,F644as in option 1 when you upload a website.
The /cygdrive rule exists because a colon in an rsync path means "remote host". We checked this with Linux rsync 3.4.1: a source written as C:/Users/me/site/ made rsync try to connect to a server called c:
ssh: Could not resolve hostname c: Name or service not known rsync: connection unexpectedly closed (0 bytes received so far) [Receiver] rsync error: error in rsync protocol data stream (code 12) at io.c(232) [Receiver=3.4.1]
With a remote destination as well, it stopped with The source and destination cannot both be remote.
Error: rsync not found on the server
rsync starts a second copy of itself on the server over SSH. If the server has no rsync, the server's shell reports rsync: command not found and the local rsync fails like this (lab output):
rsync: connection unexpectedly closed (0 bytes received so far) [sender] rsync error: error in rsync protocol data stream (code 12) at io.c(232) [sender=3.4.1]
Install it on the server with sudo apt install rsync (Debian, Ubuntu) or sudo dnf install rsync (AlmaLinux, Rocky Linux; AlmaLinux 10 installed rsync 3.5.0 in our lab) and run the command again.
Alternatives when you do not need rsync
- scp from PowerShell: according to Microsoft, Windows 10 (build 1809) and later and Windows Server 2019 and later can use the OpenSSH client, which includes
scp. It copies everything every time; see how to copy folders with scp -r. - WinSCP: its synchronize command and the matching GUI function compare folders and upload only changed files. WinSCP does not use the rsync protocol (rsync support is an open request in its issue tracker), so each changed file is sent in full.
- robocopy: Microsoft's built-in copy tool is for local folders and Windows network shares (for example
\\server\share), not for Linux servers over SSH.robocopy C:\site D:\backup /MIRmirrors a folder;/MIRalso deletes extra files in the destination.
rsync over SSH works with any Ucartz KVM VPS (full root access) or dedicated server. To use a VPS as an off-site copy of your files, see back up your files with rsync and a VPS.
Related articles: how to use rsync to copy and sync files in Linux, how to rsync only new or changed files, how to set up SSH keys, how to run Linux on Windows with WSL.
Official documentation: Install WSL, File permissions for WSL, rsync manual.