Tag Archives: automate

Simple automated backup with Robocopy

Linux / Unix systems have Rsync, a very useful tool that does what it sounds like it does. Remote sync directories and files. It has a number of options and can be used in conjunction with SSH for secure syncing. Whilst there’s a version available for Windows called CWRsync, which operates in the Cygwin environment, it didn’t quite work in my situation.

Since Windows Vista, Microsoft have included a command line tool called Robocopy. However there are gui’s available, see Wiki entry. Robocopy like Rsync, has a number of options and defaults to only copying the source files to the destination if they’re newer or of different sizes.

With something like the simple batch script below, you can automate backups. You could assign this to a schedule in Windows but strangely I prefer to run it manually. I’ll only mention the options I’ve used as there are quite a few.

Syntax is Robocopy

Robocopy “c:\users/me\My Documents\source” \\server\home\me /s /xo /FFT /Z /log+:”c:\users\me\My Documents\scripts\backup.log”

/s. Copy all non empty sub directories. /e will copy all including empty ones.
/xo. Exclude copying files if the destination version is the same or newer than the source.
/Z. Resume mode, in case of network problems.
/fft. FAT File times, 2 second granularity. I read of some people having problems with source dates not being correctly calculated and the source being copied in it’s entirety each time. Using this switch was given as a possible resolution.

Note the quotes in the source path. Needed if you have any spaces in file / folder names.

The last line echo, makes the internal speaker beep when done. There’s actually a character after the echo which has not been displayed here. How to obtain it for a script Open a command prompt. Windows key + r, type cmd.
Echo ^g > beep.txt

Then copy and paste the contents of beep.txt after your echo statement.

Robocopy on Wikipedia