Dec 15 2012

Windows Remote Server/NAS Sync and Backup Files

Published by at 3:35 pm under Backup,Windows

robocopy is a tool that copies files but more interestingly, it lets you synchronize data from a server (or a NAS) to another Windows server. It is provided with the Windows 2003 Server resource kit tools or natively in Windows 2008 Server and above.
Synchronization takes little bandwidth with Robocopy and can be a good way to backup files over a slow network link.
Here is a DOS script that synchronises data from a remote server’s shared folders to a local server. It could be the other way around of course. Any usual backup software can then handle files copied locally, saving them to tape if you wish.
Backup software do not provide agents we can install on a NAS most of the time. I use this sync script for remote sites with files hosted on a NAS or a Windows server that do not have a backup software locally.

@echo off

set EXCLUDE_DIR="Shares Not To be Backed Up"

rem Go through server/NAS shares
for /F "tokens=1 delims=" %%K in ^
  ('net view %REMOTE_NAS%^|findstr Disk^|findstr /V %EXCLUDE_DIR%') do (
  rem Sync files in the share
  for /F "tokens=1 delims=#" %%S in ("!SHARELINE!") do (
    set SHARE=%%S
    echo Processing \\%REMOTE_NAS%\!SHARE!...
    robocopy "\\%REMOTE_NAS%\!SHARE!" "%LOCAL_DIRECTORY%\!SHARE!" ^
    /XF *.avi Thumbs.db /XD Temp* /E /COPY:DAT /R:0 /W:1 /NP

Save with a BAT extension as with any DOS script. Change settings according to your setup and create a scheduled task to be run over night in Windows task scheduler.

No responses yet

Comments RSS

Leave a Reply