Skip to content

Replicate files from Windows to FreeNAS

Rsync is a remote and local synchronization tool, it uses an algorithm that minimizes the amount of data copied by only moving the portions of files that have changed. it is a built-in tool in Linux. To use it in Windows, either install WSL or download third-party rsync.

In this post, I will demo how to sync files from the Windows server to FreeNAS.

Install Rsync on Windows

Download link: https://www.itefix.net/cwrsync, extra files to `C:\rsync\` folder.

Create secrets

Enter the username and password that has been created in FreeNAS. the format of secrets is username: password

gosysops:123456

develop a batch script and deploy it in Windows schedule task

@echo on
cd C:\Rsync\bin\
rsync.exe -vzrtopgu --progress --delete --ignore-existing  /cygdrive/F/gosysops/Backup/  gosysops@203.109.200.200::gosysops --password-file=/cygdrive/C/Rsync/rsync.secrets" 

-v: show detailed information

-z: compress file data during the transfer

-r: recurs into directories

-t: preserve modification times

-p: same as –partial –progress

-g: preserve group

-u: skip files that are newer on the receiver

–progress: show progress during transfer

–delete: delete extraneous files from destination dirs

if you run the script as a schedule task and your files are stored on the NAS. you need to add `map` command before the rsync in the script. this is because batch script will run as a system user, it uses a different profile/environment.

@echo on
net use Y: \\192.168.1.7\Volume_1 /persistent:no
cd C:\Rsync\bin\
rsync.exe -vzrtopgu --progress --delete --ignore-existing  --exclude={'April-2020-b018*','Jan-2020'} /cygdrive/y/gosysopsbackup/  gosysops@203.109.200.200::gosysops --password-file=/cygdrive/C/Rsync/rsync.secrets"  >> c:\rsynclog.txt

Configure Rsync Modules on FreeNAS

Navigate and expand rsync menu, click “add Rsync Modules”, then enter Modelue name, Path, User and Group.

image

Leave a Reply