win-tips-und-tricks.txt

robocopy backup script

Robocopy uses Mirroring, but XCopy does not use it. 

It is used to mirror or synchronize directories. 

So instead of copying the total amount of files directly 

from one directory to another, 

Robocopy checks the destination directory first and removes 

all the files that are no longer present in the main tree.

To test it BEFORE running it live - add a /L switch, 

this will just do a dry run on the data and show you 

in the logs what gets backed up

PS D:\> robocopy /MIR /l /log:d:\robocopy.log /ts /tee /fp /v /zb /r:3 /w:1 D:\ E:\Backups\hpelitebook840g3-D\

( dryrun copy with subfolders )

robocopy d:\testfiles \\la-srv-lab02\temp$\dst /copyall /e /log:c:\temp\dst.log /zb /r:3 /w:1

/MIR mirror the source and destination directory -> not backwards

/E       copy subdirectories, including Empty ones.

/L switch, this will just do a dry run on the data

/S       copy Subdirectories, but not empty ones

/PURGE       delete dest files/dirs that no longer exist in source.

/MIR MIRror a directory tree (equivalent to /E plus /PURGE).

/ZB    Copy files in restartable mode, if access is denied, 

restart the copy action in backup mode. This will override 

files and folder permissions that might block access.

/R:n   number of Retries on failed copies: default 1 million.

/W:n Wait time between retries: default is 30 seconds.

/LOG 

Option         Description

/LOG:<path>        Specify the log file to save the information to

/LOG+:        Append the result to an existing log file

/ts      Include the source file time stamp in the log output

/tee   Output to log and console

/fp     Include the full path of the files in the log

/v       Verbose, output also skipped files