I'm looking for a Linux equivalent of the command Robocopy /CREATE, which recreates a complete empty file tree with all the attributes of folders and files in the source, except the files' contents. Rsync, which is said to be the equivalent of Robocopy for general file synchronization purposes, doesn't seem to have a similar option.

I'm recovering data from a 4TB hard disk drive, with the main partition formatted in Ext4, so far I could clone 47% with HDDSuperClone until it started to suffer serious issues, but the partition is still not accessible on the recovery drive, while recovery softwares like R-Studio and DMDE can't reconstruct the original metadata structure, and the drive's current degraded condition may not allow to recover significantly more useful data.

So, since the original drive can still be mounted on Lubuntu (albeit with difficulty), if I have to resort to “raw file carving”, i.e. scan the recovered data with tools that detect file signatures and extract all detected files in bulk (I'm using mainly R-Studio and Photorec for that purpose), I'd like to at least provide the drive's owner with a way of sorting such a mess more conveniently than doing it from scratch with no reference.

Obviously, in such a context, the command I'm looking for should proceed quickly and only analyze a few key filesystem structures, not involve a thorough scan of the partition which would only wear out that drive further.

  • Have you looked at this Rsync-related article online: “Linux: rsync Copy Directories Structures Tree Only” Seems like it can do what you are asking to do. – Giacomo1968 May 26 '19 at 3:40
  • Thank you for this quick reply, but apparently the proposed command copies directories only, what I'd like is the strict equivalent of Robocopy /CREATE, which also copies files, but with a size of 0 byte (I use that a lot to keep snapshots of file trees). It could be a script with a combination of commands. I read about the touch command which can create empty files, perhaps a simple script could create an empty file on the destination for each file in the source, with the same name, path, if possible timestamps. But I'm not familiar enough with the Linux environment to write such a script. – GabrielB May 26 '19 at 4:20
  • Well, asking for a script to be written is not going to go over well here, but I see what you mean and think it’s a decent question. – Giacomo1968 May 26 '19 at 4:22
  • 2
    Not exactly what you need - but if linux sees it - gnu ddrescue might be worth a try – Journeyman Geek May 26 '19 at 8:38
  • 1
    GNU ddrescue is a good first step. It will rescue as much of the disk raw data as it can. Then you work with the copy, so you certainly don't "wear out that drive further". – Kamil Maciorowski May 26 '19 at 8:51

There is --attributes-only option for cp. It's not required by POSIX, so not every implementation of cp will understand it; still cp from GNU coreutils in your Lubuntu does support it.

don't copy the file data, just the attributes

It creates files of size 0. To copy a directory tree you need -R, so

cp -R --attributes-only /path/to/mountpoint/ /where/to/copy/to
  • 2
    Thanks, I'll try that, it seems to be exactly what I'm looking for. – GabrielB May 26 '19 at 14:28

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.