Script de Instalação do Rsync no Windows
  • PowerShell 100%
Find a file
Itamar Campos d04c4f11b4
feat: adiciona instalador automatizado de rsync para Windows
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
2026-06-22 15:01:51 -05:00
assets feat: adiciona instalador automatizado de rsync para Windows 2026-06-22 15:01:51 -05:00
src feat: adiciona instalador automatizado de rsync para Windows 2026-06-22 15:01:51 -05:00
.gitattributes feat: adiciona instalador automatizado de rsync para Windows 2026-06-22 15:01:51 -05:00
.gitignore feat: adiciona instalador automatizado de rsync para Windows 2026-06-22 15:01:51 -05:00
LICENSE feat: adiciona instalador automatizado de rsync para Windows 2026-06-22 15:01:51 -05:00
README.en-US.md feat: adiciona instalador automatizado de rsync para Windows 2026-06-22 15:01:51 -05:00
README.md feat: adiciona instalador automatizado de rsync para Windows 2026-06-22 15:01:51 -05:00

PowerShell Logo

RsyncOnWin

Automated rsync Installer for Windows via Winget, Chocolatey or MSYS2

License: MIT PowerShell Platform Admin pt-BR en-US


Table of Contents


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 rsync installation (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.zst packages from the official MSYS2 repository (rsync, libxxhash, libzstd)
  • Creation of an rsync.bat wrapper in C:\Windows for use without Git Bash
  • Automatic addition of the rsync directory to the machine-level PATH
  • 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 at https://forge.itamarcampos.com.br/itamcampos/rsynconwin.

Credential safety: Avoid writing passwords as plain text in shared terminal environments. Prefer storing credentials with Get-Credential and 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 using rsync -e ssh --protocol=29.


Contributing

Suggestions and improvements are welcome. Open an issue or submit a pull request.


Made by your-username