Home robocopy
Post
Cancel

robocopy

on a Windows server, Robocopy can be used to simply back local data up to a remote share;

Place the following in a batch file and schedule to run via windows task scheduler:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
@ECHO OFF
SETLOCAL
SET _source=D:\aestiva\cgi-bin\

SET _dest=\\NAS\e$\Backup\cgi-bin

SET _what=/COPYALL /ZB /SEC /E

:: /COPYALL :: COPY ALL file info
:: /ZB :: copy files in restartable, falling back to Backup mode.
:: /SEC :: copy files with SECurity
:: /MIR :: MIRror a directory tree
:: /E :: copy all subfolders

SET _options=/R:5 /W:15 /LOG:D:\BackUp\backup.log /NP /NDL /RH:2200-0600 /PF

:: /R:n :: number of Retries
:: /W:n :: Wait time between retries
:: /LOG :: Output log file
:: /NP :: no progress logging
:: /NFL :: No file logging
:: /NDL :: No dir logging
:: /RH:hhmm-hhmm :: run hours. only operate during these times
:: /PF :: check time on a per file basis



ROBOCOPY %_source% %_dest% %_what% %_options%

The above script will copy files only during the specified period. If it has started a file copy and then the run rime has elapsed before the copy can complete, it will complete the copy. With a big file, this may introduce problems.

If you don’t want it running after a specified time (ie users log in) then create a bat filecalled ‘kill_robocyp.bat with the following line in it and run it when you want robocopy to die. It will then continue the next night

1
taskkill /IM robocopy.exe /F
This post is licensed under CC BY 4.0 by the author.