none
Robocopy: can MIR or PURGE delete files from Source ? RRS feed

  • Question

  • Windows 7 Home Premium 64-bit

    This tutorial says that the /MIR flag may cause Robocopy to delete files on the Source:
    http://www.sevenforums.com/tutorials/187346-robocopy-create-backup-script.html

    Is that true? If it is true, presumably the same warning should apply to the /PURGE option?

    Here's the relevant quote from that article:

    Use the /MIR option with caution - it has the ability to delete a file from both the source and destination under certain conditions.

    This typically occurs if a file/folder in the destination has been deleted, causing ROBOCOPY to mirror the source to the destination. The result is that the same files in the source folder are also deleted. To avoid this situation, never delete any files/folders from the destination - delete them from the source, and then run the backup to mirror the destination to the source.

    If in doubt, do not use the /MIR option, but be aware that backups will take longer.

    I want to use Robocopy to do regular backups about 400 GB of media files. I want the external HD to replicate what's in my media folder on the internal HD. So, anything changed or added to the Source should be copied to the Destination, anything deleted from Source should be deleted from Destination. I do not want Robocopy to delete anything from Source.

    The backup will be run every few days, as media files on Source may be edited, added, deleted by me.

     


    Wednesday, December 28, 2011 1:54 PM

Answers

  • According to the documentation and some simple tests I ran today, the /MIR option does not erase anything from the source.  The tutorial mentioned above is just flat wrong.  Here's the truth, arrived at by typing "robocopy /?" at a command prompt:

     /MIR :: MIRror a directory tree (equivalent to /E plus /PURGE)

    And further:

     /E :: copy subdirectories, including Empty ones.

    /PURGE :: delete dest files/dirs that no longer exist in source.

    Don't take my word for it.  Sometimes these options change with different versions.  The only way to know for sure is to read the help, create your command, and do some tests.

    • Marked as answer by franklin-xy Friday, February 24, 2012 6:26 PM
    Thursday, February 2, 2012 6:44 PM
  • Shoutinblues, thanks for the reply!

    My test results are similar to yours. I've not found a situation where Robocopy deletes files from the source. I've tried MIR and PURGE, and I have not seen that behaviour.

    I think the information in that article I quoted, and the information from MSFT CSG Arthur Xie, are just plain wrong. At least, I can find no authoritative corroboration of what they say, and my own tests cannot confirm it, nor can yours.

    Thanks for reporting on your tests! :) 


    • Edited by franklin-xy Thursday, February 2, 2012 6:56 PM
    • Marked as answer by franklin-xy Friday, February 24, 2012 6:26 PM
    Thursday, February 2, 2012 6:55 PM

All replies

  • This option mirror a directory tree. Therefore it will do two-ways sync. Just do not delete anything in the destination. Otherwise, if you do not accept it, use Windows Backup instead.
    Please remember to click “Mark as Answer” on the post that helps you, and to click “Unmark as Answer” if a marked post does not actually answer your question. This can be beneficial to other community members reading the thread. ”
    Friday, December 30, 2011 3:00 AM
    Moderator
  • Thanks for the reply.

    What about /PURGE ? Will that go one-way only, or will that also potentially delete items from the source directory?

    .

    EDIT: Sorry Arthur, but all the research I've done, and my own testing, say that your answer is entirely wrong. /MIR does not delete any files from source.



    • Edited by franklin-xy Friday, February 24, 2012 6:26 PM
    Friday, December 30, 2011 4:12 AM
  • The /PURGE deletes destination files and directories that no longer exist in the source

    For more details, please refer to:

    Robocopy
    http://technet.microsoft.com/en-us/library/cc733145(WS.10).aspx


    Please remember to click “Mark as Answer” on the post that helps you, and to click “Unmark as Answer” if a marked post does not actually answer your question. This can be beneficial to other community members reading the thread. ”
    • Proposed as answer by Xsakorov Friday, October 6, 2017 6:10 AM
    Friday, December 30, 2011 5:53 AM
    Moderator
  • Right, but does that mean that PURGE will not delete anything from the source?

    I do not want to use MIR, as I do not want Robocopy ever to delete or modifying any files on the source disk. I want to use Robocopy to keep a backup drive up-to-date as an exact copy of what's on the source drive.

    I want Robocopy to add or update files on the destination drive if those files were first added to or updated by me on the source. I want Robocopy to delete files and folders from the destination if I deleted them from the source. I don't want Robocopy to delete anything from the source or modify anything on the source. That's why I won't use MIR, now that you confirmed that Robocopy may delete or affect files on source when MIR is used.

    Is PURGE safe for my needs? Will PURGE allow Robocopy only to make changes to the destination?

    Friday, December 30, 2011 5:04 PM
  • Did you try FSMT(File Server Migration Tool???) . Have a robocopy GUI it´s called a Richcopy, very good work in threads. Try this!!!!! If Help´s classify!

     

    Thanks!

    Gustavo Luiz


    Gustavo Luiz Albino Gonçalves - MCP W2K Server/Professional - MCTS SQL Server 2005
    Tuesday, January 3, 2012 4:49 PM
  • Hi, thanks for replying.

    I've never tried FSMT, I will search for info about it.

     

    RichCopy is not a GUI to Robocopy. RichCopy is a separate technology, and I read reviews of it but it still has some bugs and has not been maintained for a while.

    There is a Robocopy GUI from an MS staffer, which I will try. But, the GUI is just frontend for Robocopy, so still the issue I want to know about is whether Robocopy PURGE does what I want (since people say that MIR can delete items from source, and I don't want that to happen).

    Tuesday, January 3, 2012 7:18 PM
  • According to the documentation and some simple tests I ran today, the /MIR option does not erase anything from the source.  The tutorial mentioned above is just flat wrong.  Here's the truth, arrived at by typing "robocopy /?" at a command prompt:

     /MIR :: MIRror a directory tree (equivalent to /E plus /PURGE)

    And further:

     /E :: copy subdirectories, including Empty ones.

    /PURGE :: delete dest files/dirs that no longer exist in source.

    Don't take my word for it.  Sometimes these options change with different versions.  The only way to know for sure is to read the help, create your command, and do some tests.

    • Marked as answer by franklin-xy Friday, February 24, 2012 6:26 PM
    Thursday, February 2, 2012 6:44 PM
  • Shoutinblues, thanks for the reply!

    My test results are similar to yours. I've not found a situation where Robocopy deletes files from the source. I've tried MIR and PURGE, and I have not seen that behaviour.

    I think the information in that article I quoted, and the information from MSFT CSG Arthur Xie, are just plain wrong. At least, I can find no authoritative corroboration of what they say, and my own tests cannot confirm it, nor can yours.

    Thanks for reporting on your tests! :) 


    • Edited by franklin-xy Thursday, February 2, 2012 6:56 PM
    • Marked as answer by franklin-xy Friday, February 24, 2012 6:26 PM
    Thursday, February 2, 2012 6:55 PM
  • Gustavo, como entro em contato com vc ? Estou com sua carteira. michaelfontes@gmail.com.

    flw

    Friday, February 24, 2012 6:20 PM
  • It is true that it should not delete anything however I have been migrating a great amount of files lately and now that I have come to a Server 2008 R2 x64 it seems that a lot of files in the source have gone missing. Or to put it another way:

    I am currently migrating user homedrives from one server to another. The procedure goes as follows:

    I create a new home drive for the user by running a script. So the directory created might have had different rights (and most definently a different name), but that should not be a problem. After the new folder is created I will simply run:

    Robocopy \\oldserver\oldshare$\olddirectory \\newserver\newshare$\newdirectory /COPYALL /MIR /R:1 /W:1

    Some source directories vanish, others will remain. There is no possibility to determine why one would vanish or why one would stay. On the other hand I had absolutely no trouble running robocopy on a 2003 Server, no directories did vanish it worked as it should.

    At the present time this is no problem, since I would have deleted the original folder anyway. But as soon as I need to rely on the files being on both sides the next morning, this could cause serious trouble.

    Cheers

    Marf

    • Edited by Marf1987 Thursday, April 12, 2012 11:17 AM
    Thursday, April 12, 2012 11:15 AM
  • I totally agree with the tutorial as I fell victim today to MIR switch. I tried using Robocopy first time ever today and was trying to make a copy of the whole data drive on a Windows 2008 R8 server to an external drive.  I used /MIR switch without ever knowing that it will delete files/folders from the Source Folder if it would not exist on the destination drive.

    Ultimately I ended up deleting the whole source drive ! Luckily I had a recent Windows Backup which I shall used to restoring files.

    I warn everyone to carefully use /MIR switch. Try to avoid it as much as possible.

    Tariq

    Sunday, May 20, 2012 11:39 AM
  • Are you sure you didn't reverse source and target paths in the Robocopy string? I've done many tests, and have not yet seen Robocopy delete any items from source.

    Microsoft's own documentation about Robocopy does not say that MIR will delete items from source, only from target.

    Sunday, May 20, 2012 12:41 PM
  • Franklin, I've also been using Robocopy with the /MIR switch and it has not deleted the source files.

    I've tested the batch many times, testing it on the network, unplugging the cable, deleting the destination files to see if it deletes the source files and it hasn't deleted the source files yet on my tests.

    robocopy %userprofile%\Documents I:\backup\documents\ *.* /MIR /W:2 /R:3 /XJ /MT /XF *.pst *.exe /LOG:C:\backups\backupLog.txt

    Windows 7 Pro commands.

    Also if you're copying to a location that uses a file system (NTFS, FAT, ext2) that isn't the one you're using, try using the /FFT switch.
    • Edited by rnicolas Wednesday, May 30, 2012 3:36 PM
    Wednesday, May 30, 2012 3:26 PM
  • Bingo. Always a risk when you use lots of drive mappings, so when robocopying over the network I prefer to use UNC paths.

    It might sound a dummy thing to do - confuse your Z:\ and your Y:\ - but if you do it right 999 times and wrong 1 time you'll lose data.

    Friday, October 31, 2014 4:36 AM
  • Robocopy /MIR will only delete files in the destination directory and only when they were first deleted from the source directory.  It does not modify the files in the source directory.  If you delete files in the destination folder, Robocopy will replace them next time you run it.

    Thursday, February 9, 2017 9:56 PM
  • so... for those of you who ended up here because it DID delete the source ... well just wanted to confirm that it can and will clear both directories... AND I HAVE NO IDEA WHY.  


    Luckily I have a back up of both, but still this is crazy, I ran the /MIR on two picture folders  that i wanted to merge and ... it cleared both of them out completely.  Any ideas why this would have happened?


     
    Started : Thursday, January 11, 2018 9:52:33 PM

       Source : C:\Users\Charles\ownCloud\Pictures\
         Dest : \\server\Users\Charles\Pictures\

        Files : *.*

      Options : *.* /S /E /DCOPY:DA /COPY:DAT /PURGE /MIR /R:1000000 /W:30

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

                               0    C:\Users\Charles\ownCloud\Pictures\
            *EXTRA Dir        -1    \\server\Users\Charles\Pictures\BB944\
              *EXTRA File              1.0 m        IMG_20160427_220931_panorama.jpg
              *EXTRA File              1.4 m        IMG_20160427_220957.jpg
              *EXTRA File              1.5 m        IMG_20160427_221030.jpg
              *EXTRA File              1.3 m        IMG_20160427_221044.jpg
              *EXTRA File              1.4 m        IMG_20160427_221105.jpg
              *EXTRA File              1.4 m        IMG_20160427_221123.jpg
              *EXTRA File              1.2 m        IMG_20160427_221133.jpg
              *EXTRA File              1.4 m        IMG_20160427_221140.jpg
              *EXTRA File              1.3 m        IMG_20160427_221146.jpg
              *EXTRA File              1.4 m        IMG_20160427_221156.jpg
            *EXTRA Dir        -1    \\server\Users\Charles\Pictures\BB944\camera\
              *EXTRA File              6.5 m        3401817-5752246198-32021.jpg
              *EXTRA File             906435        IMG_20170129_104611.jpg
              *EXTRA File              1.6 m        IMG_20170129_104626.jpg
              *EXTRA File              1.3 m        IMG_20170129_104636.jpg
              *EXTRA File              1.2 m        IMG_20170131_100218.jpg
              *EXTRA File              1.4 m        IMG_20170131_103314.jpg
              *EXTRA File              1.1 m        IMG_20170201_072744.jpg
              *EXTRA File              1.2 m        IMG_20170205_142856.jpg
              *EXTRA File             239103        IMG_20170205_153426.jpg
              *EXTRA File              1.2 m        IMG_20170208_082203.jpg
              *EXTRA File              1.3 m        IMG_20170208_082530.jpg
              *EXTRA File            1015957        IMG_20170213_091348_edit.jpg
            *EXTRA Dir        -1    \\server\Users\Charles\Pictures\BLACKBERRY-252C\
            *EXTRA Dir        -1    \\server\Users\Charles\Pictures\BLACKBERRY-252C\camera\
              *EXTRA File              61203        IMG_20150522_165548.png
              *EXTRA File              50751        IMG_20150522_165602.png
              *EXTRA File              85365        IMG_20151215_155653.png
              *EXTRA File             185124        IMG_20160118_220455.png
              *EXTRA File              1.2 m        IMG_20160310_100049.jpg
              *EXTRA File              1.5 m        IMG_20160310_100052.jpg
              *EXTRA File              1.4 m        IMG_20160310_100055.jpg
              *EXTRA File              1.4 m        IMG_20160310_100058.jpg
              *EXTRA File              1.4 m        IMG_20160310_100102.jpg
              *EXTRA File              2.6 m        IMG_20160310_100142_panorama.jpg
              *EXTRA File            1038780        IMG_20160310_100207.jpg
              *EXTRA File              1.2 m        IMG_20160310_100222.jpg
              *EXTRA File              1.1 m        IMG_20160310_100728.jpg
              *EXTRA File              1.1 m        IMG_20160310_100903.jpg
              *EXTRA File            1004622        IMG_20160310_101553.jpg
              *EXTRA File              1.1 m        IMG_20160310_101753.jpg
              *EXTRA File              1.1 m        IMG_20160310_102052.jpg
              *EXTRA File             931400        IMG_20160310_102102.jpg
              *EXTRA File              1.2 m        IMG_20160310_102111.jpg
              *EXTRA File            1029125        IMG_20160310_102536.jpg
              *EXTRA File              1.0 m        IMG_20160310_102544.jpg
              *EXTRA File              1.3 m        IMG_20160310_122449.jpg
              *EXTRA File              1.2 m        IMG_20160310_122519.jpg
              *EXTRA File              1.2 m        IMG_20160312_142838.jpg
              *EXTRA File              1.2 m        IMG_20160402_131633.jpg
              *EXTRA File              1.3 m        IMG_20160403_162954.jpg
              *EXTRA File             997588        IMG_20160407_163328.jpg
              *EXTRA File              1.2 m        IMG_20160407_180633.jpg
              *EXTRA File              2.5 m        IMG_20160425_084827.jpg
              *EXTRA File            1039390        IMG_20160425_103835.jpg
              *EXTRA File              24318        IMG_20160503_113018.png
              *EXTRA File              1.2 m        IMG_20160506_155338.jpg
              *EXTRA File              1.6 m        IMG_20160506_155403.jpg
              *EXTRA File              1.2 m        IMG_20160510_143945.jpg
              *EXTRA File              1.4 m        IMG_20160510_144001.jpg
              *EXTRA File             939635        IMG_20160511_082352_hdr.jpg
              *EXTRA File            1023420        IMG_20160517_093057.jpg
              *EXTRA File              1.2 m        IMG_20160527_105432.jpg
              *EXTRA File              1.2 m        IMG_20160527_105450.jpg
              *EXTRA File              1.1 m        IMG_20160527_105505.jpg
              *EXTRA File              1.1 m        IMG_20160527_142832.jpg
              *EXTRA File              1.2 m        IMG_20160531_082638.jpg
              *EXTRA File              1.5 m        IMG_20160531_082647.jpg
              *EXTRA File              1.4 m        IMG_20160531_082654.jpg
              *EXTRA File              1.2 m        IMG_20160531_082701.jpg
              *EXTRA File              1.5 m        IMG_20160531_082709.jpg

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

                   Total    Copied   Skipped  Mismatch    FAILED    Extras
        Dirs :         1         0         1         0         0        30
       Files :         0         0         0         0         0       912
       Bytes :         0         0         0         0         0   1.569 g
       Times :   0:00:09   0:00:00                       0:00:00   0:00:09
       Ended : Thursday, January 11, 2018 9:52:42 PM


    Friday, January 12, 2018 6:19 AM
  • Robcopy /MIR and /PURGE will not delete files from the source. They delete files only from the destination.

    Your log shows files and directories being deleted from the destination, because they no longer exist on the source. Perhaps something or someone inadvertently deleted those items from the source. Once you ran Robocopy it saw that those items no longer existed in source, so it properly executed the /PURGE /MIR commands and deleted the files from the destination.

    Friday, January 12, 2018 3:43 PM
  • Mirroring is not safe when involving NTFS reparse points. It will delete files both from the destination and source depending on the changes mirrored. You can check my article

    https://mlvnt.com/2018/01/where-robocopy-fails/

     on the topic for an in-depth explanation.



    • Edited by mlvnt Saturday, January 20, 2018 5:08 PM
    Friday, January 19, 2018 10:03 PM
  • This option mirror a directory tree. Therefore it will do two-ways sync. Just do not delete anything in the destination. Otherwise, if you do not accept it, use Windows Backup instead.
    Please remember to click “Mark as Answer” on the post that helps you, and to click “Unmark as Answer” if a marked post does not actually answer your question. This can be beneficial to other community members reading the thread. ”
    Kindly delete this answer, Mr. Arthur Xie. It's wrong and confuses the readers. RoboCopy /MIR does NOT delete any files from the source folder.

    Ramesh Srinivasan  |  The Winhelponline Blog


    Wednesday, June 12, 2019 4:51 AM
    Answerer