ROBOCOPY - Create Backup Script

Page 3 of 32 FirstFirst 1234513 ... LastLast

  1. Posts : 207
    Windows 7 Professional 64bit
       #20

    Thank you Golden, I have to report Progress, of sorts!

    Below is copied from the screen shot after running the program.


    C:\Users\Alans PC\Documents>robocopy C:\Users\Alans PC\TEST FOLDER F:\Outlook Data Files /e /np /tee /mt:4 /log:my_backup_log.txt

    -------------------------------------------------------------------------------
    ROBOCOPY :: Robust File Copy for Windows

    -------------------------------------------------------------------------------

    Started : Wed Mar 21 10:12:08 2012

    Source - C:\Users\Alans\
    Dest - C:\Users\Alans PC\Documents\PC\TEST\

    Files : FOLDER

    Options : /COPY AT /R:1000000 /W:30

    ------------------------------------------------------------------------------

    ERROR : Invalid Parameter #4 : "F:\Outlook"

    Simple Usage :: ROBOCOPY source destination /MIR

    source :: Source Directory (drive:\path or \\server\share\path).
    destination :: Destination Dir (drive:\path or \\server\share\path).
    /MIR :: Mirror a complete directory tree.

    For more usage information run ROBOCOPY /?

    **** /MIR can DELETE files as well as copy them !

    C:\Users\Alans PC\Documents>pause
    Press any key to continue . . .

    END.

    The destination is as follows, copied from the address bar of my F: drive as text.

    F:\Outlook Data Files

    I note that the source and destination are both C:

    Source - C:\Users\Alans\
    Dest - C:\Users\Alans PC\Documents\PC\TEST


    The above does not agree with the script you wrote or I copied to notepad, I wondered if my original script was somehow corrupting this one so I deleted my original and tried again with the same result.

    Perhaps you could shed some light on what maybe wrong.

    Many thanks.
      My Computer


  2. Posts : 2,177
    Windows 8.1 Pro x64
       #21

    Whenever there is a space in the file path you need to put quotes around it.

    e.g.
    "C:\Users\Alans PC\Documents\PC\TEST"

    Just to keep it simple for a second, does it work if you try:
    robocopy "C:\Users\Alans\" "C:\Users\Alans PC\Documents\PC\TEST"
    Regards,
    JDobbsy1987
      My Computer


  3. Posts : 207
    Windows 7 Professional 64bit
       #22

    Hi JDobbsy1987.

    Thanks for that suggestion, I have added the quotation marks to my script which is now looking like:

    robocopy "C:\Users\Alans PC\TEST FOLDER" "F:\Outlook Data Files" /e /np /tee /mt:4 /log:my_backup_log.txt
    pause
    I put a File in my TEST FOLDER called 'calender 2012' on running the above script I now have a copy of the 'calender 2012' file in my F:\Outlook Data Files Folder.

    I would have thought that I would be copying the whole folder, in my case TEST FOLDER to my F: Drive, as in the instruction: "C:\Users\Alans PC\TEST FOLDER".

    The following is copied from the CMD prompt window.

    C:\Users\Alans PC\Documents>robocopy "C:\Users\Alans PC\TEST FOLDER" "F:\Outlook
    Data Files" /e /np /tee /mt:4 /log:my_backup_log.txt

    Log File : C:\Users\Alans PC\Documents\my_backup_log.txt

    -------------------------------------------------------------------------------
    ROBOCOPY :: Robust File Copy for Windows

    -------------------------------------------------------------------------------

    Started : Wed Mar 21 16:40:11 2012

    Source : C:\Users\Alans PC\TEST FOLDER\
    Dest : F:\Outlook Data Files\

    Files : *.*

    Options : *.* /TEE /S /E /COPY AT /NP /MT:4 /R:1000000 /W:30

    ------------------------------------------------------------------------------

    *EXTRA Dir -1 F:\Outlook Data Files\Outlook - OLD Pre 2012\
    *EXTRA Dir -1 F:\Outlook Data Files\Outlook Files - NEW 21 03
    2012\
    1 C:\Users\Alans PC\TEST FOLDER\
    100% New File 120320 calendar 2012.xls

    ------------------------------------------------------------------------------

    Total Copied Skipped Mismatch FAILED Extras
    Dirs : 1 0 1 0 0 2
    Files : 1 1 0 0 0 0
    Bytes : 117.5 k 1 17.5 k 0 0 0 0
    Times : 0:00:00 0:00:00 0:00:00 0:00:00

    Ended : Wed Mar 21 16:40:12 2012

    C:\Users\Alans PC\Documents>pause
    Press any key to continue . . .
    If I wish to copy 'Folder XX' to my F: drive should I have put 'Folder XX' in my TEST FOLDER? I.e not the individual file.

    Perhaps the headers showing;
    ...........Total Copied Skipped Mismatch FAILED Extras
    Dirs : ......1 ......0 ........1 .........0 ..........0 .......2
    Files : .....1 ......1 ........0 .........0 ..........0 .......0

    May have something to do with it?

    Anyway at last I have been able to copy a file with 2 key strokes instead of many strokes and less chance of errors.

    Will this script automatically overwrite the preceding copy when the script is run again, replacing copy 1 with copy 2 etc?
    Last edited by Trapper; 21 Mar 2012 at 12:33.
      My Computer


  4. Posts : 2,177
    Windows 8.1 Pro x64
       #23

    Trapper said:
    I would have thought that I would be copying the whole folder, in my case TEST FOLDER to my F: Drive, as in the instruction: "C:\Users\Alans PC\TEST FOLDER".
    Robocopy copies the 'contents' of the folder you specify in the script as opposed to the actual folder itself.


    Trapper said:
    If I wish to copy 'Folder XX' to my F: drive should I have put 'Folder XX' in my TEST FOLDER? I.e not the individual file.
    The answer is yes :)


    Trapper said:
    Will this script automatically overwrite the preceding copy when the script is run again, replacing copy 1 with copy 2 etc?
    I'm pretty certain it will overwrite the preceding copy, it did when i tested before writing this reply.



    Robocopy has a lot of features/switches to allow you to do quite a lot, you can take a look at these by running the following command in a command prompt:

    Code:
    robocopy /?
    If you do want to make your script go that step further then please feel free to open a support thread in the forum and send me a pm and i will do my best to mentor you through as much as i can

    Regards,
    JDobbsy1987
      My Computer


  5. Posts : 19,383
    Windows 10 Pro x64 ; Xubuntu x64
    Thread Starter
       #24

    Hi,

    Yes, Dobsy is correct : when source and/or destinations have spaced in them, enclose the folders with " ". I might add that to the tutorial.

    Each time you run ROBOCOPY without the /MIR switch, it will always overwite the preceeding copy - in effect it operates like XCOPY. If you add the /MIR switch to your ROBOCOPY command, then only the newest information in that folder is copied to your backup. This is a great time-saving feature.

    Regards,
    Golden
      My Computer


  6. Posts : 207
    Windows 7 Professional 64bit
       #25

    Gentlemen.

    Thank you both for your kind assistance with these problems of mine, I have printed off the Robocopy switches (A very long list!)

    I will now have a play over the next day or so and see what I can achieve.

    I will leave the /mir switch out until I am more confident, I have time but with my luck I will screw it up and lose the original files.

    If I need to post into which forum would this come under, it could cover a few listed?
      My Computer


  7. Posts : 19,383
    Windows 10 Pro x64 ; Xubuntu x64
    Thread Starter
       #26

    Your very welcome Trapper.

    If you need to post further, just post under the "Backup & Restore" section. I'm confident you will be using the /MIR switch in no time at all.

    There is only one trick to remember with /MIR:

    If you have a folder that is already backed-up and you no longer require it - always delete it at the source (NOT at the destination) and then run ROBOCOPY. This way, ROBOCOPY will take care of it (delete it) at the destination for you automatically (this is the mirroring effect). Follow that rule, and you will never go wrong with the /MIR switch :)

    In summary:

    1, Delete folder at source
    2. Run ROBOCOPY with /MIR switch
    3. Folder is automatically deleted for you at destination.

    Regards,
    Golden
      My Computer


  8. Posts : 5
    Windows 7 Pro
       #27

    Excluding Folders that are many levels deep.


    Golden;
    In my folder structure, every project has subfolders named Archive, Inbox, Temp, etc. They are always 4 levels below the drive root, but the parent project name is unique. Is there a way to exclude these subfolders?

    Thanks much,
    Ron
      My Computer


  9. Posts : 2,177
    Windows 8.1 Pro x64
       #28

    rschaef07 said:
    Golden;
    In my folder structure, every project has subfolders named Archive, Inbox, Temp, etc. They are always 4 levels below the drive root, but the parent project name is unique. Is there a way to exclude these subfolders?

    Thanks much,
    Ron
    Hi Ron

    As long as you don't add one of these switches it should not copy subdirectories:

    /e or /s

    Example, change Golden's example from
    Code:
    robocopy E:\Data1 G:\Backups\Data1 /e /mir /np /log:backup_log.txt
    to
    Code:
    robocopy E:\Data1 G:\Backups\Data1 /mir /np /log:backup_log.txt
    Regards,
    JDobbsy1987
      My Computer


  10. Posts : 5
    Windows 7 Pro
       #29

    Some folders yes, some folders no


    Understood. But at that same level (4 deep from the root) are the folders that are the core of our projects and need to be backed up...
    Is there a way to not back up some that are identically named and located but not others at the same folder depth?

    Thanks, Ron
      My Computer


 
Page 3 of 32 FirstFirst 1234513 ... LastLast

  Related Discussions
Our Sites
Site Links
About Us
Windows 7 Forums is an independent web site and has not been authorized, sponsored, or otherwise approved by Microsoft Corporation. "Windows 7" and related materials are trademarks of Microsoft Corp.

© Designer Media Ltd
All times are GMT -5. The time now is 15:38.
Find Us