- PowerShell 100%
Implementa script PowerShell para instalação e configuração do rsync no Windows com suporte a três estratégias em ordem de prioridade: Chocolatey, e fallback manual via pacotes .tar.zst do MSYS2. Ao final, cria wrapper rsync.bat em C:\Windows para disponibilizar o comando em cmd.exe e PowerShell sem depender do Git Bash. Arquivos incluídos: - src/RsyncOnWin.ps1: script principal de instalação - README.md: documentação em pt-BR - README.en-US.md: documentação em en-US - assets/: recursos visuais do projeto - LICENSE, .gitignore, .gitattributes: configuração do repositório |
||
|---|---|---|
| assets | ||
| src | ||
| .gitattributes | ||
| .gitignore | ||
| LICENSE | ||
| README.en-US.md | ||
| README.md | ||
Table of Contents
- Overview
- Features
- Prerequisites
- Installation and Usage
- Remote Execution (irm/iex)
- Parameters
- Installation Strategy
- Command-Line Wrapper
- Examples
- Contributing
Overview
RsyncOnWin is a PowerShell script that installs and configures rsync on Windows in a fully automated, unattended manner. It attempts three installation methods in priority order — Winget, Chocolatey, and a manual MSYS2 fallback — ensuring that rsync is available in both cmd.exe and PowerShell without relying on Git Bash.
At the end of the installation, an rsync.bat wrapper is created in C:\Windows, making the rsync command globally accessible from any terminal.
Features
- Automatic detection of an existing
rsyncinstallation (avoids unnecessary reinstallation) - Installation via Winget (Git for Windows + MSYS2 catalog packages, when available)
- Installation via Chocolatey (automatic Chocolatey setup if absent +
choco install rsync) - Manual fallback: direct download of
.tar.zstpackages from the official MSYS2 repository (rsync,libxxhash,libzstd) - Creation of an
rsync.batwrapper inC:\Windowsfor use without Git Bash - Automatic addition of the
rsyncdirectory to the machine-levelPATH - Automatically accepts all Winget license agreements (
--accept-package-agreements --accept-source-agreements) - Colored, structured logging with levels:
Info,Success,Warning,Error,Debug - Post-installation verification with a summary report
- Automatic cleanup of temporary files
Prerequisites
- Windows 10 1809+ / Windows 11 / Windows Server 2022+ (x64)
- Windows PowerShell 5.1+ or PowerShell 7+
- Administrator privileges (required)
- Internet access (for package downloads)
- Winget (App Installer) — recommended but not required
Installation and Usage
Option 1 — Clone the repository
git clone https://github.com/your-username/RsyncOnWin.git
cd RsyncOnWin
.\RsyncOnWin.ps1
Option 2 — Direct download
Download RsyncOnWin.ps1 and run it in a terminal with Administrator privileges:
.\RsyncOnWin.ps1
Note: When running a script downloaded from the internet, Windows may require the execution policy to allow local scripts. Run the command below once if needed:
Set-ExecutionPolicy -Scope CurrentUser RemoteSigned
Important: The script requires Administrator privileges. Right-click on PowerShell and select "Run as Administrator" before proceeding.
Remote Execution (irm/iex)
Run the script directly from the internet without cloning the repository:
Simple execution
irm https://forge.itamarcampos.com.br/itamcampos/rsynconwin/raw/branch/main/RsyncOnWin.ps1 | iex
Using the system proxy:
irm https://forge.itamarcampos.com.br/itamcampos/rsynconwin/raw/branch/main/RsyncOnWin.ps1 -Proxy ([System.Net.WebRequest]::GetSystemWebProxy().GetProxy("https://forge.itamarcampos.com.br")) -ProxyUseDefaultCredentials | iex
Specifying proxy address, port, username and password manually:
irm https://forge.itamarcampos.com.br/itamcampos/rsynconwin/raw/branch/main/RsyncOnWin.ps1 -Proxy "http://proxy.company.com:8080" -ProxyCredential (New-Object PSCredential("username", (ConvertTo-SecureString "password" -AsPlainText -Force))) | iex
Execution with parameters
& ([scriptblock]::Create((irm https://forge.itamarcampos.com.br/itamcampos/rsynconwin/raw/branch/main/RsyncOnWin.ps1))) -Verbose -ForceFallback -SkipPause
Using the system proxy:
& ([scriptblock]::Create((irm https://forge.itamarcampos.com.br/itamcampos/rsynconwin/raw/branch/main/RsyncOnWin.ps1 -Proxy ([System.Net.WebRequest]::GetSystemWebProxy().GetProxy("https://forge.itamarcampos.com.br")) -ProxyUseDefaultCredentials))) -Verbose -ForceFallback -SkipPause
Specifying proxy address, port, username and password manually:
& ([scriptblock]::Create((irm https://forge.itamarcampos.com.br/itamcampos/rsynconwin/raw/branch/main/RsyncOnWin.ps1 -Proxy "http://proxy.company.com:8080" -ProxyCredential (New-Object PSCredential("username", (ConvertTo-SecureString "password" -AsPlainText -Force)))))) -Verbose -ForceFallback -SkipPause
Security notice: Always inspect scripts before running them via
iex. Review the source code athttps://forge.itamarcampos.com.br/itamcampos/rsynconwin.
Credential safety: Avoid writing passwords as plain text in shared terminal environments. Prefer storing credentials with
Get-Credentialand reusing them:$cred = Get-Credential # opens a secure prompt for username and password irm <url> -Proxy "http://proxy.company.com:8080" -ProxyCredential $cred | iex
Parameters
| Parameter | Type | Default | Description |
|---|---|---|---|
-SkipPause |
Switch | — | Suppresses the interactive pause at exit (useful for automation) |
-ForceFallback |
Switch | — | Skips Winget and Chocolatey; forces the manual MSYS2 fallback |
-Verbose |
Switch | — | Enables detailed console output |
-Debug |
Switch | — | Enables internal debug output (implies -Verbose) |
Installation Strategy
The script attempts to install rsync in three stages, stopping at the first one that succeeds:
1. Is rsync already installed?
└─ Yes → nothing to do; create wrapper and exit
└─ No ↓
2. Is Chocolatey available (or installable)?
└─ Yes → choco install rsync -y
└─ No ↓
3. Manual fallback (MSYS2)
├─ Ensures Git for Windows (via Winget or direct installer)
└─ Downloads and extracts .tar.zst packages from MSYS2 repository:
• rsync-3.4.4-1-x86_64.pkg.tar.zst
• libxxhash-0.8.3-1-x86_64.pkg.tar.zst
• libzstd-1.5.7-1-x86_64.pkg.tar.zst
Note about
-ForceFallback: When this parameter is passed, stages 1 and 2 are skipped and the script goes directly to the MSYS2 manual fallback.
Command-Line Wrapper
At the end of installation, the script automatically creates C:\Windows\rsync.bat with the following content:
@echo off
"C:\path\to\rsync.exe" %*
This allows using the rsync command directly in any terminal — cmd.exe or PowerShell — without needing Git Bash or manually adding anything to the PATH.
Examples
Default run — tries Chocolatey, then MSYS2 if needed:
.\RsyncOnWin.ps1
Verbose mode with debug — shows every internal step:
.\RsyncOnWin.ps1 -Verbose -Debug
Force manual fallback — skips Winget and Chocolatey, uses MSYS2 directly:
.\RsyncOnWin.ps1 -ForceFallback -SkipPause
Silent run for automation — no interactive pause at the end:
.\RsyncOnWin.ps1 -SkipPause
Verify installation after the script — open a new terminal and run:
rsync --version
Basic rsync usage after installation:
# Sync a local folder
rsync -avz C:\source\ C:\destination\
# Sync to a remote server via SSH
rsync -avz C:\source\ user@server:/path/to/destination/
Note about rsync over SSH: In some Windows 11 environments, the error
error in rsync protocol data stream (code 12)may occur when using remote SSH. If that happens, check rsync version compatibility on the server and consider usingrsync -e ssh --protocol=29.
Contributing
Suggestions and improvements are welcome. Open an issue or submit a pull request.