soze Posted May 30, 2008 Posted May 30, 2008 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.
Quackers Posted May 30, 2008 Posted May 30, 2008 Robocopy "C:\" "D:\BackupFolder" /MIR should do it, but add your timeouts to it. 1
Michael Posted May 30, 2008 Posted May 30, 2008 Quackers is right, that should work. Here's a good reference of all command switches. As far as I can it's the "C:\*.*" which is incorrect.
srochford Posted May 30, 2008 Posted May 30, 2008 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. 1
soze Posted May 30, 2008 Author Posted May 30, 2008 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!
FN-GM Posted May 30, 2008 Posted May 30, 2008 For anyone who isn't the best with the commands this might help Utility Spotlight: Robocopy GUI 1
Michael Posted May 30, 2008 Posted May 30, 2008 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.
soze Posted May 30, 2008 Author Posted May 30, 2008 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.
FN-GM Posted May 30, 2008 Posted May 30, 2008 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.
Michael Posted May 30, 2008 Posted May 30, 2008 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!
ajbritton Posted May 30, 2008 Posted May 30, 2008 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 1
ajbritton Posted May 30, 2008 Posted May 30, 2008 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 1
srochford Posted May 31, 2008 Posted May 31, 2008 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 2
FN-GM Posted May 31, 2008 Posted May 31, 2008 Nice one, when "thanks" work again i will give you one for that. 1
soze Posted June 2, 2008 Author Posted June 2, 2008 thanks for all the help, do I copy the script to the USB Drive? I have very little scripting knowledge.
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now