Posts Tagged ‘tool’

Moved + Robocopy

May 13, 2008

This blog moved

Some things were broken on my selfhosted wordpress installation, and I had no time to look into it, so I moved to clohyment.wordpress.com. As it is hosted and maintained by the creators of wordpress, it is in good hands and frees me from keeping the wordpress installation up to date, applying security and other fixes. It was a smooth transition as I didn’t have many posts/customizations to move. In short: exporting the posts from the old site to an xml file, importing that at wordpress.com, fixing some links and the operation was finished.

Robocopy

Robocopy.exe is Microsoft’s file copy and synchronization swiss army knife. It’s a commandline tool not unlike Gnu’s rsync. Vista has it out-of-the-box, but you can download it for XP/2003 as part of the Windows Resource Toolkit.
My favorite feature is copying/syncing across fileshares using UNC paths thus without the need to mount them to a drive letter first. The worst “feature” is that it retries a failed filecopy ONE MILLION times by default, waiting 30 seconds between each attempt. This means if a temp file dissapears while syncing or if a file is locked (typically outlook .pst file), your nightly backup operation will never finish. Lucky you can easily disable this behavior. Using these switches: /W:0 /R:0 robocopy will continue copying immediately even if 1 file can’t be copied. There are numerous other advanced features like bandwith throtling, monitoring a folder for changes and triggering a copy after x changes, ….

Some robocopy tricks:

  • Only copy permissions, no data
    During a file migration from and old to a new Win2003 server, all data had been copied across using explorer (conventional copy and paste). This means the original permissions were NOT kept, as the user doing the copying becomes the owner of them and they get their permissions from the new parent folder.
    I didn’t have the time to repeat the entire copy operation with a tool that is able to maintain permissions, so I used robocopy to only copy permissions without the data:

    robocopy \\oldserver\c$\test c:\test /IS /S /COPY:SOU /W:0 /R:0

    The secret is the /COPY:SOU switch which means:

    • S = Security ACLS (ntfs permissions)
    • O = Owner info
    • U = aUditing info

    There is no D so no data is copied. I don’t know if permission copying works with with Samba shares.Another tool that does this is permcopy, also part of the windows resource toolkit:

    permcopy \\oldserver sharename \\newserver sharename

    At the time I didn’t know there’s a free all-in-one tool called “Fileserver Migration Tool” from MS that obsoletes the need to manually move every individual share. It takes care of moving the shares (data+share perms+ntfs perms) to the new server and disabling them on the old server afterwards. A similar utility is available for migrating an MS printserver.

  • Set-and-forget backup.bat script
    @echo off
    robocopy c:\importantdocs \\backuphost\backup /MIR /ZB /W:0 /R:0 /LOG:backuplog.txt /NFL /NDL

    This keeps \\backuphost\backup share in sync with c:\importantdocs and creates a logfile. Be warned that the /MIR switch means that files that don’t exist in the source (c:\importantdocs) WILL BE DELETED from the destination (\\backuphost\backup) !! Thus if source is empty, destination will be wiped out to, be carefull! The /ZB switch is for restartable and backup mode. Restartable mode is handy for copying large files over unstable links, backup mode uses some magic that increases robocopy’s ability to copy open files. /NFL and /DFL make sure only failed files and dirs are logged.
    Knowing myself, if I’d have to run this manually I would forget about it and don’t have a backup. To automate this you can create a Windows sheduled task that runs when the computer is no user activity on the computer for 10 minuts.
    Ofcourse there exist other smarter and better backup methods but this is one free and fast method for off-machine or even off-site backup.