A simple ROBOCOPY task, I think not!
We finally received our PowerEdge 1950 Hard Drive Trays. I placed a 180GB SATA HD on the tray and screwed that bad boy up and placed it in the second bay. Remote into the server, open up Computer Management and formatted the HD [NTFS] and assigned it the letter E [easy right?].
Task:
- copy everything in the D drive to a folder called d_backup in the E drive.
- do it in a monthly scheduled task
Ideas:
- manually copy and paste everything over to E:\d_backup and do it monthly [Ha!]
- work smarter and not harder approach and script this task
Solution:
- What do you think? 😉
So I didn’t know what to use xcopy or robocopy? I used both in the past, but robocopy in my opinion was more robust due to it’s “mirror” mode, which keeps the folder structure in sync. I went to Microsoft TechNet Library to look at the parameters for the command. These are the ones that caught my eye:
Option | Description |
---|---|
/s | Copies subdirectories. Note that this option excludes empty directories. |
/e | Copies subdirectories. Note that this option includes empty directories. |
/mir | Mirrors a directory tree |
/tee | Writes the status output to the console window, as well as to the log file |
/log+:<logfile> | Writes the status output to the log file as Unicode text appends the output to the existing log file |
The Script:
echo on
ROBOCOPY D:\ E:\d_backup /s /e /mir /tee /log+:"E:\copylogs.txt"
The Problem:
Even though the script is straight forward in the eyes of a System Administrator, but when the script was done I looked in the E: drive and did not find the d_backup folder. The log file stated that it was successful and the HD dropped down to 165GBs, so I know something was copied.
Research:
I did some research and found this article File and Folder – Hide or Unhide. Now, it’s not that simple. I didn’t bother to check the files in the D drive because there were some system files that will automatically make it hidden if I used xcopy or robocopy. [ Who know?? Seriously?? LOL: got to love technology]
Solution:
You could use the ATTRIB command to unhide the files that are protected by the operating system:
ATTRIB -H -S "Full Path of File with extension"
Once I figured out why the folder was disappearing and fixed it, I opened task scheduler and created my task to run my *.bat file on the first Monday of each month.
Leave a Reply