CWrsync

Logiciel rsync recompilé avec Cygwin pour fonctionner sous Windows. A noter que depuis la version 1.7 de Cygwin, il support les chemins unicodes (type //?/c:/). Il peut donc synchroniser des dossiers avec des chemins de plus de 30'000 caractères).

Le logiciel de base peut être téléchargé à l'adresse suivante : https://www.itefix.net/content/cwrsync-free-edition.

Pour le VSS (copie des fichiers en cours d'utilisation), il faut avoir le Windows Development Toolkit : https://www.microsoft.com/en-us/download/details.aspx?id=3138.

CWrsync fonctionne sur un environnement Cygwin. Les chemins d'accès utilisent donc des slashs et les disques logiques de windows se trouve dans le dossier /cygwin. Le chemin d'accès du dossier Windows (par exemple) est donc /cygwin/c/windows/. Pour les synchronisations récursives, il faut bien mettre le slash final.

Exemple de script de synchronisation :

CWRSYNC.CMD
@ECHO OFF
REM *****************************************************************
REM
REM CWRSYNC.CMD - Batch file template to start your rsync command (s).
REM
REM Created by Tevfik K. (http://itefix.no)
REM Modified by Remi B. (http://wcentric.com)
REM *****************************************************************
 
REM Make environment variable changes local to this batch file
SETLOCAL
 
REM ** CUSTOMIZE ** Specify where to find rsync and related files (C:\CWRSYNC)
SET "CWRSYNCHOME=%PROGRAMFILES(x86)%\CWRSYNC"
 
REM Set HOME variable to your windows home directory. That makes sure 
REM that ssh command creates known_hosts in a directory you have access.
SET "HOME=%HOMEDRIVE%%HOMEPATH%"
 
REM Make cwRsync home as a part of system PATH to find required DLLs
SET "CWOLDPATH=%PATH%"
SET "PATH=%CWRSYNCHOME%;%PATH%"
 
REM Windows paths may contain a colon (:) as a part of drive designation and 
REM backslashes (example c:\, g:\). However, in rsync syntax, a colon in a 
REM path means searching for a remote host. Solution: use absolute path 'a la unix', 
REM replace backslashes (\) with slashes (/) and put -/cygdrive/- in front of the 
REM drive letter:
REM 
REM Example : C:\WORK\* --> /cygdrive/c/work/*
REM 
REM Example 1 - rsync recursively to a unix server with an openssh server :
REM
REM       rsync -r /cygdrive/c/work/ remotehost:/home/user/work/
REM
REM Example 2 - Local rsync recursively 
REM
REM       rsync -r /cygdrive/c/work/ /cygdrive/d/work/doc/
REM
REM Example 3 - rsync to an rsync server recursively :
REM    (Double colons?? YES!!)
REM
REM       rsync -r /cygdrive/c/doc/ remotehost::module/doc
REM
REM Rsync is a very powerful tool. Please look at documentation for other options. 
REM
 
REM ** CUSTOMIZE ** Enter your rsync command(s) here
 
REM Create shadow copy and mount on drive H:
REM CALL :shadowRun
 
REM If you use Shadow Copy, use drive H instead of C.
rsync -va "/cygdrive/c/Windows.old/" "/cygdrive/e/Windows.old/"
 
REM Delete shadow copy
REM CALL :shadowClean
 
REM Copy permissions
CALL :permsCopy
 
GOTO :EOF
 
:ShadowRun
WHERE vshadow.exe > NUL 2> NUL
IF ERRORLEVEL 1 (
  echo VSS not avalaible. Install Windows SDK.
  GOTO :EOF
)
echo Preparation VSS
vshadow.exe -p -nw "-script=%TEMP%\vars.bat" C:
CALL "%TEMP%\vars.bat"
 
echo Shadow sur C:
vshadow.exe -el=%SHADOW_ID_1%,H:
pause
GOTO :EOF
 
:ShadowClean
WHERE vshadow.exe > NUL 2> NUL
IF ERRORLEVEL 1 (
  echo VSS not avalaible. Install Windows SDK.
  goto :EOF
)
 
echo
echo Clean Shadow
vshadow.exe -ds=%SHADOW_ID_1%
GOTO :EOF
 
:permsCopy
ROBOCOPY "C:\\Windows.old\\" "D:\\Windows.old\\" /XO /XN /XC /E /COPY:ATSO
pause
GOTO :EOF