+ Post New Thread
Results 1 to 11 of 11
Coding Thread, robocopy help in Coding and Web Development; Think this should be easy. Im trying to make a batch file that runs daily. I am using robocopy to ...
  1. #1

    Join Date
    Jul 2010
    Posts
    557
    Thank Post
    65
    Thanked 21 Times in 18 Posts
    Rep Power
    13

    robocopy help

    Think this should be easy.

    Im trying to make a batch file that runs daily. I am using robocopy to copy the data across

    So I have
    Code:
    robocopy c:\source D:\dest /MIR /DCOPY:t
    however instead of it copying to D:dest i would like to to copy to D:backup(todaysdate)

  2. #2
    VeryPC_Tom_M's Avatar
    Join Date
    Aug 2012
    Location
    Sheffield
    Posts
    388
    Thank Post
    14
    Thanked 82 Times in 79 Posts
    Rep Power
    44
    Quote Originally Posted by MattDLEA View Post
    Think this should be easy.

    Im trying to make a batch file that runs daily. I am using robocopy to copy the data across

    So I have
    Code:
    robocopy c:\source D:\dest /MIR /DCOPY:t
    however instead of it copying to D:dest i would like to to copy to D:backup(todaysdate)
    Try
    Code:
    robocopy c:\source d:\backup%date:~-4,4%%date:~-7,2%%date:~-10,2% /MIR /DCOPY:t

  3. #3
    TheCrazyTechnician's Avatar
    Join Date
    Jun 2012
    Location
    South Yorkshire
    Posts
    19
    Thank Post
    4
    Thanked 1 Time in 1 Post
    Rep Power
    7
    sorry to ask a different question but I'm setting Robocopy up now and just want to ask, does the MIR switch mean that the copy will be incremental? I've read that on another site but want to make sure that's correct before i include it

  4. #4

    Steve21's Avatar
    Join Date
    Feb 2011
    Location
    Swindon
    Posts
    2,689
    Thank Post
    334
    Thanked 515 Times in 483 Posts
    Rep Power
    179
    Quote Originally Posted by TheCrazyTechnician View Post
    sorry to ask a different question but I'm setting Robocopy up now and just want to ask, does the MIR switch mean that the copy will be incremental? I've read that on another site but want to make sure that's correct before i include it
    No, Mir is mirror. aka create exact same copy.

    To create incrementals I generally base it on then archive bit, thus only do files that have changed each time.

    Steve

  5. Thanks to Steve21 from:

    TheCrazyTechnician (23rd October 2012)

  6. #5

    Steve21's Avatar
    Join Date
    Feb 2011
    Location
    Swindon
    Posts
    2,689
    Thank Post
    334
    Thanked 515 Times in 483 Posts
    Rep Power
    179
    If anyones interested (and now that I'm at home) this is what I'm running at home for our backups to NAS.

    Code:
    md "\\MYNAS\StevePC\%date:/=-% D Backup"
    
    robocopy D:\ "\\MYNAS\StevePC\%date:/=-% D Backup" /LOG:"\\MYNAS\StevePC\%date:/=-% D Backup\Log.txt" /TEE /NDL /M /S /R:0 /W:2 /XJ /B /XF *thumbs.db* *ntuser.dat* /XD "$RECYCLE.BIN" "System Volume Information" "ProgramData" "C:\Windows" "C:\Program Files" "C:\Program Files (x86)" *Temporary* "C:\Users\Steve\Favorites"
    To explain it a bit:

    Code:
    md "\\MYNAS\StevePC\%date:/=-% D Backup"
    Make new folder daily for changes to pc.

    Code:
    robocopy D:\ "\\MYNAS\StevePC\%date:/=-% D Backup"
    Copy D drive to my NAS with todays date in folder.

    Code:
    /LOG:"\\MYNAS\StevePC\%date:/=-% D Backup\Log.txt"
    Write logs to log file.

    Code:
    /TEE /NDL /M /S /R:0 /W:2 /XJ /B
    Output to console as well as log
    Don't log folder names, only files
    Only copy files with archive bit (then remove archive) aka incremental
    Copy sub folders
    No retries
    Ignore junction points
    Use backup operator (stops permission issues)

    Code:
    /XF *thumbs.db* *ntuser.dat* 
    /XD "$RECYCLE.BIN" "System Volume Information" "ProgramData" "C:\Windows" "C:\Program Files" "C:\Program Files (x86)" *Temporary* "C:\Users\Steve\Favorites"
    Ignore certain files, and directories.



    So every time it runs it'll create a new folder on my NAS, and only copy files that have changed/new into it, log it and mark it all not to archive again.

    Steve

  7. Thanks to Steve21 from:

    zag (23rd November 2012)

  8. #6
    zag
    zag is offline
    zag's Avatar
    Join Date
    Mar 2007
    Posts
    3,762
    Thank Post
    897
    Thanked 416 Times in 350 Posts
    Blog Entries
    12
    Rep Power
    86
    Great stuff. I've just setup robocopy to mirror our main file server with a batch file whenever I feel like it.

    Works really well so far.

  9. #7
    irsWorkshop's Avatar
    Join Date
    Dec 2012
    Posts
    4
    Thank Post
    0
    Thanked 0 Times in 0 Posts
    Rep Power
    0
    Better than using scripts and/or batch files is to use Karen Replicator;

    Karen's Replicator

    Does the writing for you.

  10. #8

    Join Date
    Jul 2010
    Posts
    557
    Thank Post
    65
    Thanked 21 Times in 18 Posts
    Rep Power
    13
    Sorry to bring this back up but does /MIR mean I dont have to use /B

    I understand that /B is back up mode ( but what is back up mode?)

    So say if I want to copy user directories from the server to a NAS if I have to do a restore from the NAS to the server is it posible for me to run the batch file but just swap the source and dest paths around. Or would i have to play around with permisions?

    Or would a COPYALL or SEC be more usefull?
    Last edited by MattDLEA; 16th January 2013 at 11:33 AM.

  11. #9

    Steve21's Avatar
    Join Date
    Feb 2011
    Location
    Swindon
    Posts
    2,689
    Thank Post
    334
    Thanked 515 Times in 483 Posts
    Rep Power
    179
    Quote Originally Posted by MattDLEA View Post
    Sorry to bring this back up but does /MIR mean I dont have to use /B

    I understand that /B is back up mode ( but what is back up mode?)

    So say if I want to copy user directories from the server to a NAS if I have to do a restore from the NAS to the server is it posible for me to run the batch file but just swap the source and dest paths around. Or would i have to play around with permisions?
    B and MIR are nothing at all linked. B uses a super user with backup operator so you can copy files that normally you don't have access to. (Even those that admins have denied access to)

    In terms of the copying back, honestly not sure, haven't tried doing it with the same line

    Steve

  12. Thanks to Steve21 from:

    MattDLEA (16th January 2013)

  13. #10

    Join Date
    Jul 2010
    Posts
    557
    Thank Post
    65
    Thanked 21 Times in 18 Posts
    Rep Power
    13
    Thanks Steve,

    I mean if i use

    Code:
    robocopy c:\Staffprofiles NAS:\backupstaffprofiles /MIR /DCOPY:t /COPYALL /B
    That should copy all the staff profiles and permisions.
    In our Staffprofile folder we have joeblog(folder) which i can get in to and then joeblog.V2 which I cant get in to (when logged on the server as admin) not that i want to get in.

    What I'm getting at is if all staff profiles break would it be as simple as
    Code:
    robocopy NAS:\backupstaffprofiles c:\Staffprofiles /MIR /DCOPY:t /COPYALL /B
    Or would there be a different way to disaster recover?

  14. #11

    Steve21's Avatar
    Join Date
    Feb 2011
    Location
    Swindon
    Posts
    2,689
    Thank Post
    334
    Thanked 515 Times in 483 Posts
    Rep Power
    179
    Quote Originally Posted by MattDLEA View Post
    Thanks Steve,

    I mean if i use

    Code:
    robocopy c:\Staffprofiles NAS:\backupstaffprofiles /MIR /DCOPY:t /COPYALL /B
    That should copy all the staff profiles and permisions.
    In our Staffprofile folder we have joeblog(folder) which i can get in to and then joeblog.V2 which I cant get in to (when logged on the server as admin) not that i want to get in.

    What I'm getting at is if all staff profiles break would it be as simple as
    Code:
    robocopy NAS:\backupstaffprofiles c:\Staffprofiles /MIR /DCOPY:t /COPYALL /B
    Or would there be a different way to disaster recover?
    Aye looks right off hand, guess only thing you could change is with restore I'm guessing you would want things like checking if there's already a newer version etc? If some work is lost, others not. Or is this "major" disasters only?

    Steve

SHARE:
+ Post New Thread

Similar Threads

  1. RoboCopy help
    By FN-GM in forum Windows Server 2008 R2
    Replies: 8
    Last Post: 8th June 2011, 07:26 PM
  2. Robocopy help
    By bodminman in forum How do you do....it?
    Replies: 4
    Last Post: 20th January 2011, 08:22 PM
  3. Robocopy help needed
    By Jobos in forum Windows
    Replies: 1
    Last Post: 19th November 2008, 04:19 PM
  4. Robocopy Help
    By Gatt in forum Windows
    Replies: 2
    Last Post: 11th July 2008, 11:06 AM
  5. Robocopy Help
    By soze in forum How do you do....it?
    Replies: 15
    Last Post: 2nd June 2008, 02:42 PM

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •