What script do you use with robocopy?

RegEdit

New Member
Reaction score
3
Location
Pacific Palisades, CA
What script do you use with robocopy if migrating raw user data before a reinstall? I found this script on the net. I might take out "/COPYALL = copies all attributes" because I don't want to have permission problems in migrating data back into a new installation.

ROBOCOPY mydocuments maxtor /E /COPYALL /Z /R:3 /W:10 /LOG:robolog.txt /QUIT



mydocuments = source
maxtor = target
/E = copy all subdirectories even empty ones
/COPYALL = copies all attributes
/Z = copies in restartable mode
/R:3 = retry up to three times
/W:10 = wait10 seconds between retries
/LOG... = log all operations to the specified file
/QUIT = exits the command-line when done
 
I use Fabs for this job - nothing else is easier or more effective.

I do use Robocopy for backups, though. I like the /TEE switch because it displays the progress in a the cmd window. Your retry /wait settings are too long, though. I typically use 2/2.

I also never use the /quit switch, but I generally make the whole thing a batch file and then tie that to an icon and/or scheduled task, so the cmd window dismisses when done in any event. For backups, if I'm not writing a log, I make a separate text file and write a entry for when the backup started and one for when it finished.

echo Backup Started %date% %time% >>destination\backuplog.txt
 
A ghetto way to use xcopy is to run the program Delete Long Path just to identify files with names over 260 characters, then manually migrating those with copy and paste, then deleting them from the source location. Some will be temp internet files which you can just delete. Then just run xcopy.
 
A ghetto way to use xcopy is to run the program Delete Long Path just to identify files with names over 260 characters, then manually migrating those with copy and paste, then deleting them from the source location. Some will be temp internet files which you can just delete. Then just run xcopy.

To add to this, open a cmd window and type "xcopy /?" (without the quotes) to see what the valid switches are. I use xcopy to make backups of my stuff on my home computers. I just have to make sure the source & destination drive(s) are correct in my batch file (aka, script).

edit: Now that I am home I can give you the following info that I use when I do a backup via the "cmd" window using "xcopy".


@ECHO ON
REM Copies files and directory trees.
@ECHO OFF
REM XCOPY source [destination] [/A | /M] [/D[:date]] [/P] [/S [/E]] [/V] [/W]
REM [/C] [/I] [/Q] [/F] [/L] [/G] [/H] [/R] [/T] [/U]
REM [/K] [/N] [/O] [/X] [/Y] [/-Y] [/Z]
REM [/EXCLUDE:file1[+file2][+file3]...]

REM source Specifies the file(s) to copy.
REM destination Specifies the location and/or name of new files.
REM /A Copies only files with the archive attribute set,
REM doesn't change the attribute.
REM /M Copies only files with the archive attribute set,
REM turns off the archive attribute.
REM /D:m-d-y Copies files changed on or after the specified date.
REM If no date is given, copies only those files whose
REM source time is newer than the destination time.
REM /EXCLUDE:file1[+file2][+file3]...
REM Specifies a list of files containing strings. Each string
REM should be in a separate line in the files. When any of the
REM strings match any part of the absolute path of the file to be
REM copied, that file will be excluded from being copied. For
REM example, specifying a string like \obj\ or .obj will exclude
REM all files underneath the directory obj or all files with the
REM .obj extension respectively.
REM /P Prompts you before creating each destination file.
REM /S Copies directories and subdirectories except empty ones.
REM /E Copies directories and subdirectories, including empty ones.
REM Same as /S /E. May be used to modify /T.
REM /V Verifies each new file.
REM /W Prompts you to press a key before copying.
REM /C Continues copying even if errors occur.
REM /I If destination does not exist and copying more than one file,
REM assumes that destination must be a directory.
REM /Q Does not display file names while copying.
REM /F Displays full source and destination file names while copying.
REM /L Displays files that would be copied.
REM /G Allows the copying of encrypted files to destination that does
REM not support encryption.
REM /H Copies hidden and system files also.
REM /R Overwrites read-only files.
REM /T Creates directory structure, but does not copy files. Does not
REM include empty directories or subdirectories. /T /E includes
REM empty directories and subdirectories.
REM /U Copies only files that already exist in destination.
REM /K Copies attributes. Normal Xcopy will reset read-only attributes.
REM /N Copies using the generated short names.
REM /O Copies file ownership and ACL information.
REM /X Copies file audit settings (implies /O).
REM /Y Suppresses prompting to confirm you want to overwrite an
REM existing destination file.
REM /-Y Causes prompting to confirm you want to overwrite an
REM existing destination file.
REM /Z Copies networked files in restartable mode.

REM The switch /Y may be preset in the COPYCMD environment variable.
REM This may be overridden with /-Y on the command line.

@ECHO ON
REM Next line checks for existance of backup destination folder/sub-directory
REM IF NOT EXIST {destination:\exact_backup} MD {destination:\exact_backup}
if not exist m:\backup-c md m:\backup-c
REM Next line cancels backup if destination is not available
if not exist m:\backup-c goto exit
xcopy c:\*.* m:\backup-c /s /e /c /g /h /r /k /o /y
:exit
exit
 
Last edited:
Back
Top