Jump to content

Recommended Posts

Posted

I'm trying to backup the entire C drive to an external USB drive using Robocopy, what would the correct syntax be:

 

robocopy "C:\*.*" "D:\BackupFolder" /E /V /NP /ZB /R:10 /W:30

 

doesn't seem to be working.

Posted

Michael's right about the "*.*" being the problem - robocopy copies all files in the folder; you can't use it to (say) copy just the *.doc files.

 

What you can do is exclude some files - /XF *.bak *.tmp will exclude .bak and .tmp files

 

May not matter for what you're doing but I always include /sec to copy the security on files.

  • Thanks 1
Posted

Thanks for the quick response guys, removed the *.* and the quotes and everything worked.

 

Would any of you be familiar with the Auto Run command, I would like for this Robocopy string to be executed when a external USB drive is inserted into the machine with no user interaction.

 

Thanks for all the Help! :)

Posted

I don't think Robocopy can be automated as far as that, but the easiest method would be to create a batch file and schedule it to run at 6pm for example, by which time you or someone would of plugged in a USB drive.

 

Alternatively, you could just create a shortcut on your desktop and double click it once the USB drive has been connected.

Posted
I don't think Robocopy can be automated as far as that, but the easiest method would be to create a batch file and schedule it to run at 6pm for example, by which time you or someone would of plugged in a USB drive.

 

Alternatively, you could just create a shortcut on your desktop and double click it once the USB drive has been connected.

 

 

 

I wish it could be that easy, it has to be automatic; no user interaction other then plugging in the USB drive.

 

Thanks for the suggestion.

Posted
I wonder if you could make a VBS script that works in the background. Say drive letter “G” is occupied it will copy the contents to a folder.
Posted
I wonder if you could make a VBS script that works in the background. Say drive letter “G” is occupied it will copy the contents to a folder.

 

That would make sense. Not sure how difficult a script it would be though!

Posted
Michael's right about the "*.*" being the problem - robocopy copies all files in the folder; you can't use it to (say) copy just the *.doc files.

 

You can, but the syntax is along the lines of

 

robocopy (SourceDir) (DestinationDir) (FileSpec)

 

e.g.

 

robocopy C:\ D:\ *.doc

  • Thanks 1
Posted
Attached is a zip file containing a hastily cobbled together AutoIt script and INI file that will watch for the arrival of a particular drive letter. When detected, a simple directory copy (with forced overwrite) will take place and the script then waits for the drive to disappear before returning to its original wait mode. It's had very limited testing but seems to work OK.

AutoBackup.zip

  • Thanks 1
Posted

another alternative is to use WMI. This can set up somethng called an event sink which sits there waiting for an event to happen. When it does, you carry out a particular action.

 

The attached script will do just that. run it (best to use wscript because otherwise you'll see a window on screen) and it will sit in the background waiting.

 

When a USB stick is inserted, the sink event will trigger. I wrote this for something else (question here about how to check for "bad" files on a USB stick) but it's easy to adapt. Basically, when the USB device arrives it gets given a DEVICEID; this is used to find out more info about the drive including its name (not C: etc but things like harddisk0). This is then queried using WMI to get a list of partitions (USB sticks often have more than one partition)

 

finally, the routine CheckFolder is called once for each partition - it's called with the drive letter and a backslash - eg G:\

 

In that routine you could add something like:

 

Set oShell=createobject("wscript.shell")
sCmd="robocopy " & sFolder & " c:\backup /s /e"
oShell.run sCmd,7,true

 

This will copy the contents of the partition to c:\backup - you can obviously put it where you want!

usbdiskarrival2.txt

  • Thanks 2
Posted
thanks for all the help, do I copy the script to the USB Drive? I have very little scripting knowledge.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now



×
×
  • Create New...