2

I tried to mirroring an existing disks on a new disks with less space. It is very important that the file structure, attributes and ACL's are exact as on the source disk.

For this I tried robocopy.exe:

robocopy $sourceDisk $destinationDisk /mir /XD "System Volume Information" "`$RECYCLE.BIN" /copyall /r:1 /NP /NFL

That command copies all folders and files with attributes, ACL's, etc. over to the destination disk, except for the compress-attribute, i.e. files or folders which are compressed on the source disk are on the destination disk not longer compressed. This attribute is missing.

Is there an option for robocopy to do this (I didn't find it). Or are there existing other approaches to make an exact copy of an disk or file structure to another disk?

  • What operating system is this - I'm assuming some version of Windows. Isn't compression a feature of the file system - sounds like you've not turned on compression on the destination disk. – Paul Haldane Dec 2 '14 at 14:07
  • @PaulHaldane it is a Windows 7/2008 machine. – larkee Dec 2 '14 at 16:43
2

I am not aware of any version of robocopy that supports copying the Compressed attribute. (I just tested with the version that ships with Windows Server 2012 R2 just to be sure that a version newer than my Windows 7 laptop still did not include this behavior.)

If you're going to use robocopy you'll need to script something to follow-up behind it compressing files/folders that require compression. (I could imagine some kind of script that would use robocopy with the the /ia command-line argument to copy only compressed files first, compress all the copied-files, then run robocopy again using the /xa argument to copy the non-compressed files.)

In terms of copying the "exact structure" of the disk, a sector-for-sector copy would be the way to go. A tool like dd will let you do sector-for-sector copying of volumes.

If your definition of "exact structure" is less rigorous and you're just looking for an exact copy of the directory structure, file data, attributes (including compression), and ACLs I'd look at a disk-imaging tool. Microsoft's ImageX tool is one example. (You can obtain ImageX from Microsoft inside various packages-- the Windows Automated Installation kit contains a copy and, I believe, it's also included in Windows Deployment Services). There are lots of third-party tools would fit the bill, too.

  • There's a thread here suggesting the same thing (copy files and then re-apply the file compression). Includes powershell to accomplish same: social.technet.microsoft.com/Forums/windowsserver/en-US/… – BlueCompute Dec 2 '14 at 16:55
  • @BlueCompute - I'd just copy the compressed files first using robocopy with the /ia command-line argument, run a for loop to compact all the files in the destination directory, then run a second robocopy with the /xa argument to copy the non-compressed files. That leaves the job of detecting which files are compressed to robocopy. This is still sub-optimal because it results in decompression and recompression of the files, but I'm not sure that NTFS gives robocopy any way to copy the file in the compressed state anyway. – Evan Anderson Dec 2 '14 at 17:20
  • Ah yes that makes sense. I skimmed your original answer and missed that logic :-( – BlueCompute Dec 2 '14 at 17:23
  • @EvanAnderson dd does not work, because I copy from a bigger disk to a smaller one. The filesystem is afterwards not accessible. Fixing the partition table is not possible, because the disks are virtual disks managed by imdisk.exe. Robocopy and ImageX approach, which you mentioned I didn't test. I was able to manage the problem with strarc.exe. – larkee Dec 9 '14 at 14:59
1

I was able to manage this problem with the commandline tool strarc.exe from LTR-Data.

This tool copies the files, as far as I understand, on a lower layer than robocopy. All attributes, ACL's are exact on the destination like the source - even the timestamps. The junctions where also correct copied.

The command is

$srcDisk = "Y:"
$dstDisk = "Z:"
cmd /c "C:\temp\strarc.exe -cjd:$srcDisk | C:\temp\strarc -s:8 -xd:$dstDisk"

It makes a copy of the $srcDisk, i.e. Y: to $dstDisk, i.e. Z: including junctions and ignoring messages about 8.3 compability (-s:8).

I recommend this tool for exact backups via commandline.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.