Easy backup with XCOPY and Robocopy (Windows)

Configure and optimize you computer for Audio.
RELATED
PRODUCTS

Post

Recently I came across the XCOPY command, which lets you copy files with some more parameters, and thus it can be used as a simple backup utility. So I'll share this info with you... the main goal here is to be able to backup files quickly and in a simple way.
First I'll explain how to use XCOPY and its "more advanced brother": Robocopy. Then I'll write how to make a shortcut to backup files instantly. And finally, how to make a batch file (multiple copying "with a single click").


The task is: copy files from a working dir (songs...) to a backup dir on a separate hard drive, overwriting older files with the same name.


XCOPY is already included in WindowsXP (and earlier versions). So all you have to do is run it.
Here's the xcopy command for the task:

Code: Select all

xcopy d:\WorkingDir\songs\*.* e:\BackupDir\songs\ /s /e /d /y /v
You can see the two locations on drives d:\ (source) and e:\ (destination). Here's what those additinal parameters mean:
/s = copies subdirs
/e = copies also empty subdirs
/d = copies all files that are newer than the destination files
/y = don't need to confirm overwriting of files
/v = verifies that the copy is identical to the original
(The complete list of parameters can be found here.)


Robocopy is similar to XCOPY but has some advanced features. It's not included in WindowsXP by default (it is in Vista, tho) so if you want to use it there you have to install it either with the Server 2003 Resource Kit Tools or by downloading the .zip file on this page (recommended). Just extract robocopy.exe to C:\Windows\System32.
To do the same task with Robocopy is a bit simpler, since the command is "smarter":

Code: Select all

robocopy d:\WorkingDir\songs e:\BackupDir\songs /e /zb
/e = replaces both /s and /e from xcopy
/zb = a copying procedure (an extra, not available in xcopy)
All the other parameters I used in xcopy are performed by default in Robocopy.
(The complete list of parameters can be found in the .doc file, included in robocopy.zip or here, for example.)

A small tip: if the name of the folder has space in the name (like My Folder) then you have to use quotes in the command. For example:
robocopy d:\my folder e:\backup is wrong and won't work.
robocopy "d:\my folder" e:\backup is the right way to do it.


How to launch either of these commands?
1. In "Run..." from the Start menu (or the command line in Total Commander)
2. With a shortcut (or a button in Total Commander's button bar)
3. With a GUI, like this one.

The 1st and 3rd ways are pretty straight forward, so I'll explain how to make a shortcut, which is also the quickest way to make frequent backups:
1. R-click on an 'empty space' in Windows (on the Desktop or inside a folder)
2. New -> Shortcut
3. Type the command and then the name for the shortcut
4. To change the icon R-click on the shortcut -> Properties -> Change Icon...
(In TC you R-click on the button bar -> Change -> Add... (lots of icons in shell32.dll))



How to make multiple backups at once - from and to different locations?
Open notepad and type all the commands you need, like:

Code: Select all

robocopy d:\WorkingDir\songs e:\BackupDir\songs /e /zb
robocopy d:\WorkingDir\samples e:\BackupDir\samples /e /zb
robocopy d:\pictures f:\backup\pictures /e /zb
Then save the file with the extension .bat or .cmd (it's the same). When launching this file it will execute one copying process after another.






EDIT: updated with some info on Robocopy and batch files...
Last edited by ermi on Sun Dec 16, 2007 9:11 pm, edited 7 times in total.

Post

Hi,
Good post!
This is sound advice. In a two disk system I recommend copying everything you can from the user profile into a backup folder on the audio drive, and audio project data into a backup folder on the system drive. My batch file for doing this has become quite elaborate to make use of any available space to also replicate my sample library and synth rompler data. I usually leave the DAW running overnight so the replication batch file runs automatically via the task scheduler.I once had a failure of my sample library / synth data drive and it took many days to replace all of the data from CDs and DVDs. Additionally I picked up a USB 2 SATA adapter and a few cheap SATA disks which live on the shelf and hold system images and data backups, with audio projects archived to DVD.
In addition to the above suggestion, I would add the following Xcopy switches:

/C Continues copying even if errors occur.
/I If destination does not exist and copying more than one file,
assumes that destination must be a directory.

Here's an example from my backup batch file:
xcopy "e:\audio\*.*" "h:\backup\audio\" /D /S /E /C /I /Y

Roger :)

Post

I highly recommend using robocopy.exe instead of xcopy. It has all these feature and many more, and is more robust (hence the name). I use it all the time for backups and other tasks.

- Chris

Post

chrisharang wrote:I highly recommend using robocopy.exe instead of xcopy. It has all these feature and many more, and is more robust (hence the name). I use it all the time for backups and other tasks.

- Chris
Agreed. Robocopy has a significant amount more options than the standard xcopy does that's been around since the good ol' DOS days. It's part of the Win2k3 Admin pack. Can't live without it in the server world. Also, I have been using Cobain Backup for backups. It's donationware and works wonderfully.

Devon
Simple music philosophy - Those who can, make music. Those who can't, make excuses.
Read my VST reviews at Traxmusic!

Post

chrisharang wrote:I highly recommend using robocopy.exe instead of xcopy. It has all these feature and many more, and is more robust (hence the name). I use it all the time for backups and other tasks.

- Chris
Robocopy is indeed more robust. I tend to think of it as a tool for replicating critical data across sites. However in the five years plus I've being doing this I've never had any issues with xcopy between internal drives on a single machine. Also xcopy syntax is probably easier for the non techie to understand.

Here's a very simple working example of Robocopy syntax in case anyone wants one:
robocopy e:\test1\ h:\backup\test1\ /E /ZB

Again, this just copies any changed files. As Chris said, there are loads of additional features with Robocopy if you want to really get into the nuts and bolts.

The important thing here is to spend a few minutes setting up a data replication process so that when (not if) that drive fails you've still got your data somewhere else. At £40 for a 250Gb disk these days it's a no brainer.

Roger :)

Post

Do these utilities overcome the significant problems with Windows way of copying files and folders. many times when I have copied a large folder Windows has suddenly decided part of the way in that one file (out of maybe thousands) it doesn't want to copy - either it's locked (why that should affect a copy, not move or cut, operation feck knows!) or the filename isn't right or something stupid - and so it stops the whole process leaving you not knowing which files are still to copy and what is not and unable to skip and resume even. Stupid MS!

Post

aMUSEd wrote:Do these utilities overcome the significant problems with Windows way of copying files and folders. many times when I have copied a large folder Windows has suddenly decided part of the way in that one file (out of maybe thousands) it doesn't want to copy - either it's locked (why that should affect a copy, not move or cut, operation feck knows!) or the filename isn't right or something stupid - and so it stops the whole process leaving you not knowing which files are still to copy and what is not and unable to skip and resume even. Stupid MS!
Yes.
The /C switch in xcopy means carry on in case of an error, and because it only copies the changed files /D you can re-run the script without doing it all again. Even for manual copies it's way better than explorer. Robocopy's /ZB switch copies the file in backup mode if it can't copy it in restartable mode, and there are granular retry options available.

Post

Good - the number if times I have had to faff about trying to figure out what has copied and what hasn't I could sue Bill gates for making such a dumb OS.

Post

/C Continues copying even if errors occur.
Isn't it risky to use that, for you might get errors in copied files or something?


Interesting about robocopy... I didn't even consider it because I thought it was vista only, but now I see that in vista it's just there by default.

Now if you say that it's more reliable that's certainly a good point. I don't need many features, tho, but some would be useful, like: I see that robocopy has a mirror mode, which deletes files that are not in the source. That's not possible with xcopy, right?

I don't want to install unnecessary stuff, so I just downloaded the .zip with robocopy at the bottom of the wikipedia page. It's the same as the robocopy that comes in the 2003 Resource Kit Tools, right?

Post

interesting thread!

when i can afford a backup drive i will use this!! :hihi:

Subz

Post

ermi wrote:
/C Continues copying even if errors occur.
Isn't it risky to use that, for you might get errors in copied files or something?
If you don't do this the script just stops on the file it can't copy with an error message. If you know which files are going to be problematic then you could exclude them and not need the /C switch. It's really a kludge for saying "get everything you can without stopping".


Robocopy running as a service was the common solution to the crappy NT4 server replication across WANs back in the 90s. It's been around forever.

The mirror function would remove a file that you may want as archive but not in the source directory. I tend to archive at the end of a project removing the source but leaving the backup copy in place until that directory gets archived, so the mirror mode wouldn't fit that plan.

Post

ermi wrote: I don't want to install unnecessary stuff, so I just downloaded the .zip with robocopy at the bottom of the wikipedia page. It's the same as the robocopy that comes in the 2003 Resource Kit Tools, right?
Yeah, it looks like this version is XP010, which includes some recent fixes and features, notably the /XJ option, which ignores junctions.

- Chris

Post

Thanks, guys. I'm onto robocopy now. The mirror function will be useful to clean up some old archives of redundant files, but I won't use it all the time for those quick backups.

Now if I wanted a robocopy equivalent of such xcopy command:
xcopy d:\WorkingDir\songs\*.* e:\BackupDir\songs\ /s /e /d /y /v
I'd use this:
robocopy d:\WorkingDir\songs\ e:\BackupDir\songs\ /e /xo

/d seems to be replaced by /xo
/y - apparently not needed
/v - not needed?

Please correct me if I'm wrong and/or suggest me some other switch that would be useful.
Should I include /zb as well?


BTW, I couldn't find a MS page with the list of switches... the only one with many of them was this one and a .doc that came in the .zip file.

Post

Such things work until they let you down.

I would recommend installing cygwin and learning (really learning, taking some time to get a solid understanding of) the find, tar, and dd commands.

Post

ermi wrote: Now if I wanted a robocopy equivalent of such xcopy command:
xcopy d:\WorkingDir\songs\*.* e:\BackupDir\songs\ /s /e /d /y /v
I'd use this:
robocopy d:\WorkingDir\songs\ e:\BackupDir\songs\ /e /xo
Yep, although you shouldn't even need /xo. By default, it should only copy files that are either not in the target directory or are newer/changed. I generally use /mir for backup tasks, since that will really mirror what is in the source (including what is NOT in the source), but be very careful that this is what you in fact want to do, since /mir *will* delete files from the target if they don't exist in the source.

- Chris

Post Reply

Return to “Computer Setup and System Configuration”