Skip to content

Instantly share code, notes, and snippets.

@assiless
Forked from LuisEGR/install_rsync.ps1
Last active November 18, 2024 14:58
Show Gist options
  • Save assiless/a6b26c129bdf7f8f875bc497eff243a2 to your computer and use it in GitHub Desktop.
Save assiless/a6b26c129bdf7f8f875bc497eff243a2 to your computer and use it in GitHub Desktop.
Install rsync in Windows 11, easy
# open powershell as admin
# $HOME\install_rsync.ps1
# Download and install Git for Windows if not already installed
if (-not (Test-Path "C:\Program Files\Git\bin\git.exe")) {
Write-Host "Git for Windows not found. Downloading installer..."
Invoke-WebRequest -Uri "https://github.com/git-for-windows/git/releases/download/v2.31.1.windows.1/Git-2.31.1-64-bit.exe" -OutFile "git-installer.exe"
Write-Host "Installing Git for Windows..."
Start-Process -FilePath ".\git-installer.exe" -ArgumentList "/VERYSILENT" -Wait
Remove-Item ".\git-installer.exe"
}
# Create a temporary directory for downloads
New-Item -ItemType Directory -Path ".\rsync_temp" -Force | Out-Null
Set-Location ".\rsync_temp"
# Download the latest rsync binary package and its dependencies
Write-Host "Downloading rsync package and dependencies..."
Invoke-WebRequest -Uri "https://repo.msys2.org/msys/x86_64/rsync-3.3.0-1-x86_64.pkg.tar.zst" -OutFile "rsync.pkg.tar.zst"
Invoke-WebRequest -Uri "https://repo.msys2.org/msys/x86_64/libxxhash-0.8.2-1-x86_64.pkg.tar.zst" -OutFile "libxxhash.pkg.tar.zst"
Invoke-WebRequest -Uri "https://repo.msys2.org/msys/x86_64/libzstd-1.5.6-1-x86_64.pkg.tar.zst" -OutFile "libzstd.pkg.tar.zst"
# Extract the contents of the packages to the Git directory
Write-Host "Extracting packages..."
# https://stackoverflow.com/a/14699663/16077720
& cmd.exe '/C 7z x "rsync.pkg.tar.zst" -so | 7z x -aoa -si -ttar -o"C:\Program Files\Git" usr'
& cmd.exe '/C 7z x "libxxhash.pkg.tar.zst" -so | 7z x -aoa -si -ttar -o"C:\Program Files\Git" usr'
& cmd.exe '/C 7z x "libzstd.pkg.tar.zst" -so | 7z x -aoa -si -ttar -o"C:\Program Files\Git" usr'
# Clean up the temporary directory
Set-Location ".."
Remove-Item -Recurse -Force ".\rsync_temp"
# Create a batch file for running rsync from cmd.exe and PowerShell
# Write-Host "Creating rsync.bat file..."
# $rsyncBatContent = '@echo off' + [Environment]::NewLine + '"C:\Program Files\Git\usr\bin\rsync.exe" %*'
# New-Item -ItemType File -Path "C:\Windows\rsync.bat" -Value $rsyncBatContent -Force | Out-Null
Write-Host "rsync installation completed successfully!"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment