Sep 24, 2022

Incremental Data backup to USB disk with scheduler - robocopy

For small office server data backup where online/cloud backup is not feasible/preferred one can use robocopy function which is part of windows OS. Once we choose the command options properly, it supports full + differential backup on regular basis i.e. first time it will take full backup of data and then only changed files are backed up/added to backup destination folder which may be a USB backup disk OR network share.

Example:

robocopy \\server\D H:\1_D /S /E /XO /XF *.SYS *.EXE /XD \\SERVER\D\ABC \\SERVER\D\Soft /MT:16 /LOG+:H:\svrDlog.txt /NFL /NDL

(This command backs up \\server\D drive dirs & files to H:\1_D folder.) Pls. note that when we backup a data volume not directory (i.e. D drive here), robocopy does hides the destination folder which needs to be unhide by using Microsoft attrib command.

attrib -h -s H:\1_D

As mentioned in robocopy command /XD is to exclude source directory from backup set and /XF is to exclude specific file type from backup set. Also one can add /MAX:10485760 (to limit file size to 10MB) i.e. files greater than 10MB in size will not be backed up.

Both these commands can be used in dos batch file which can be scheduled in windows task scheduler to run at specific time. Also as mentioned LOG is appended to logfile mentioned. We can verify backup status by viewing logfile.