Anyone familair with robocopy?

Page 2 of 3 FirstFirst 123 LastLast

  1. Posts : 740
    Windows 10 x64 Pro
    Thread Starter
       #11

    Bree said:
    I use RoboCopy in a batch file to backup my user folder. There's a couple of pitfalls to be aware of. You've already found the 'retries' one. The default is a million retries waiting 30 seconds between each (that's nearly a year!). NTUser.dat was the file that it caught me out on. There's some switches to deal with that...

    ...I skip locked files with /R:0 (which would probably have fixed your 'System Volume Information' problem too).

    The other problem I had was an infinite recursion (well, until the maximum path length was exceeded) of particular folders on the destination drive. These were caused by what look like links to 'My Music', 'My Pictures', etc. in the Documents folder. They're not links, they are Junction Points, there's a switch to deal with that too.


    Type RoboCopy /? for the full list.
    lol this may be helpful. Might be able to point me back to my original method. Nothing ventured nothing gained they say. If nothing else im learning and thats always a win when you have a terroristic toddler interrupting your "alone" time every 90 seconds ;p
      My Computer


  2. Posts : 31,651
    10 Home x64 (22H2) (10 Pro on 2nd pc)
       #12

    If it helps, my batch files's commands for a full backup of all files and folders from the current location down (I'm in my user folder when I run it) are:

    Code:
    attrib +A *.* /s
    robocopy . <drive:\path> *.* /xjd /s /e /m /r:0
    The first command sets the Archive attribute for all files, /S does it for all subdirectories.
    For the RoboCopy command the . specifies the current directory as the source, the options I use mean:
    /M :: copy only files with the Archive attribute and reset it.
    /S :: copy Subdirectories, but not empty ones.
    /E :: copy subdirectories, including Empty ones.
    For subsequent incremental backups I omit the attrib command and the /e for robocopy so that only modified files (and the folders containing them) get copied.
    Last edited by Bree; 25 Aug 2017 at 20:10. Reason: added more info
      My Computers


  3. Posts : 740
    Windows 10 x64 Pro
    Thread Starter
       #13

    Bree said:
    If it helps, my batch files's commands for a full backup of all files and folders from the current location down (I'm in my user folder when I run it) are:

    Code:
    attrib +A *.* /s
    robocopy . <drive:\path> *.* /xjd /s /e /m /r:0
    The first command sets the Archive attribute for all files, /S does it for all subdirectories.
    For the RoboCopy command the . specifies the current directory as the source, the options I use mean:

    For subsequent incremental backups I omit the attrib command and the /e for robocopy so that only modified files (and the folders containing them) get copied.
    thank you again for the reply

    what does the archive attribute accomplish/do?

    In the end, what worked for me - or at least got me past the specific issue i was having (thus far) was doing the following

    robocopy U:\ C:\Users\klepp\Desktop\U /e /xf * /a-:sh /xd "System Volume Information"

    even with excluding the SVI directory the folder kept disappearing in its entirety. I had to add the remove hidden attribute and now it works fine. (added the -s switch as a "just in case" considering the reasons im using it at current i imagine it has a much higher potential to cause an issue than help anything)

    Now to try and get all folders im copying into a batch and try out this /xo thing. In the future, perhaps start adding files instead of folder heirarchy.

    Seriously glad I got to learn a little somethin somethin :)
      My Computer


  4. Posts : 740
    Windows 10 x64 Pro
    Thread Starter
       #14

    I knew id be back. Sigh.

    Ok heres where I'm at lol.

    I'm trying to now find a way to copy all my drives heirarchies individually to my flash drive one at a time. Started with the least destrructive as i mentioned before which IS my flash drive. This is the same folder which works fine if I copy it to desktop.

    Using this robocopy U:\ U:\Backups\Hierarchies\U\ /e /xf * /a-:sh /xo /xd "System Volume Information"

    It works until it gets to the Hierarchies folder then it repeats itself over n over /BackupsHierarchies/Backups/Hierarchies on and on and on.

    Any ideas whats going on?
      My Computer


  5. Posts : 4,666
    Windows 10 Pro x64 21H1 Build 19043.1151 (Branch: Release Preview)
       #15

    Archive Attribute is a switch that gets turned on each time a file is modified or created. This switch is useful for RoboCopy as you can turn the switch off with RoboCopy for each file that RoboCopy has successfully backed up.

    What Bree does, is that for initial FULL backup, he turns this attribute on for ALL his files. When RoboCopy copies the files to the backup location, it in turn turns off this switch for each and every file. Finally when Bree wants to make an incremental backup, only files that has been modified(Windows automatically turns the switch back on for modified files) will be backed up, thus saving a lot of space.

    When he wants to restore the backup, he would start by restoring the original full copy, and then process each incremental backup in order, until all backups are restored. (this is if he want to keep historical copies also of modified files, meaning he creates a new base folder each time he makes a new incremental backup)
      My Computers


  6. Posts : 4,666
    Windows 10 Pro x64 21H1 Build 19043.1151 (Branch: Release Preview)
       #16

    klepp0906 said:
    I knew id be back. Sigh.

    Ok heres where I'm at lol.

    I'm trying to now find a way to copy all my drives heirarchies individually to my flash drive one at a time. Started with the least destrructive as i mentioned before which IS my flash drive. This is the same folder which works fine if I copy it to desktop.

    Using this robocopy U:\ U:\Backups\Hierarchies\U\ /e /xf * /a-:sh /xo /xd "System Volume Information"

    It works until it gets to the Hierarchies folder then it repeats itself over n over /BackupsHierarchies/Backups/Hierarchies on and on and on.

    Any ideas whats going on?
    Yes, you must exclude the path "U:\Backup" from your robocopy command when copying within same drive.

    Why do you need to make directory structure also of system and hidden files, like "System Volume Information"? directories and files in SVI has no useful information for you at all.
      My Computers


  7. Posts : 740
    Windows 10 x64 Pro
    Thread Starter
       #17

    cant win. seeems it created a backups/hierarchies repeitition so deep, i cant even delete the file from my USB stick.

    unmounted it, moved it to the different port, tried taking ownership... nothing works.

    I right click delete, and nothing happens. No error/popup/nothing. I imagine its due to the unimaginably long directory structure. I let it run for ~5mins before i realized what it was doing/stopping it so has to be hundreds of repeititions deep.

    The usb stick has over 100gb on it so formatting isnt really an option. FML! :P
      My Computer


  8. Posts : 740
    Windows 10 x64 Pro
    Thread Starter
       #18

    slicendice said:
    Yes, you must exclude the path "U:\Backup" from your robocopy command when copying within same drive.

    Why do you need to make directory structure also of system and hidden files, like "System Volume Information"? directories and files in SVI has no useful information for you at all.
    I dont need to, i need to omit it. It was giving me issues. the /xd System Volume Information seems to not copy it, otherwise it was copying it by default.

    Also thank you for the clarification on Bree's method. I'll probably work up to that point as theres only so much that the cloud/syncing method covers and thats also not infallable. Like they always say, back up to several places which is what im attempting to do at the most rudamentary level atm.

    the /xd U:\Backup makestotal sense. Gaurantee that fixes my issue :) Thank you!
    Just hav eto figure out how to get rid of the infinate backup/hierarchy folder that exists atm now :P lol
      My Computer


  9. Posts : 4,666
    Windows 10 Pro x64 21H1 Build 19043.1151 (Branch: Release Preview)
       #19

    Try:

    Code:
    RD /S /Q U:\Backups\Hierarchies
    UPDATE: If this does not work, then we need to create a script that does some magic

    UPDATE: smartdelete.zip contains a batch file that will remove the endless directory structure in your case. Extract the containing batch file to U:\Backups and run it. This batch will remove any existing Backups, U and Hierarchies folders that exist in the folder the script is run in.

    HERE IS THE CODE
    Code:
    @echo off
    :start_process
    IF EXIST Hierarchies (
    IF EXIST Hierarchies\U (
    RENAME Hierarchies\U x
    MOVE Hierarchies\x . > nul
    RD /S /Q Hierarchies
    RENAME x U
    GOTO :start_process
    )
    RD /S /Q Hierarchies
    GOTO :process_done
    )
    
    IF EXIST U (
    IF EXIST U\Backups (
    RENAME U\Backups x
    MOVE U\x . > nul
    RD /S /Q U
    RENAME x Backups
    GOTO :start_process
    )
    RD /S /Q U
    GOTO :process_done
    )
    
    IF EXIST Backups (
    IF EXIST Backups\Hierarchies (
    RENAME Backups\Hierarchies x
    MOVE Backups\x . > nul
    RD /S /Q Backups
    RENAME x Hierarchies
    GOTO :start_process
    )
    RD /S /Q Backups
    GOTO :process_done
    )
    
    :process_done
    echo.
    echo All Directories removed SUCCESSFULLY!
    GOTO :eof
    Last edited by slicendice; 26 Aug 2017 at 11:28. Reason: Updated the script
      My Computers


  10. Posts : 740
    Windows 10 x64 Pro
    Thread Starter
       #20

    slicendice said:
    Try:

    Code:
    RD /S /Q U:\Backups\Hierarchies
    UPDATE: If this does not work, then we need to create a script that does some magic
    C:\Windows\system32>RD /S /Q U:\Backups\HierarchiesU:\Backups\Hierarchies\editedforfoulnameirenamedfolderinattempttodelete\Backups\Hierarchies\U\Backups\Hierarchies\U\Backups\Hierarchies\U\Backups\Hierarchies\U\Backups\Hie rarchies\U\Backups\Hierarchies\U\Backups\Hierarchies\U\Backups\Hierarchies\U\Backups\Hierarchies\U\B ackups\Hierarchies - The system cannot find the path specified.

    Yes its renameable and has a size of 0 aka just folders. Thank you very much for your help as this seems above my pay grade for sure. Have never ran into this before. Permissions issues, sure.. but this is just odd and rarely encountered id bet.
      My Computer


 

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

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




Windows 10 Forums