Is there a Linux equivalent of “Robocopy /CREATE”?

2

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.

GabrielB

Posted 2019-05-26T03:33:48.287

Reputation: 598

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.

– JakeGould – 2019-05-26T03:40:56.483

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 – 2019-05-26T04:20:59.257

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. – JakeGould – 2019-05-26T04:22:34.310

2Not exactly what you need - but if linux sees it - gnu ddrescue might be worth a try – Journeyman Geek – 2019-05-26T08:38:32.773

1GNU 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 – 2019-05-26T08:51:00.597

HDDSuperClone is a newer software with the same purpose as ddrescue (recovering data from defective storage devices as efficiently as possible) and a roughly similar operation, with some enhancements and added features. The problem is that this is a 4TB drive with only about 550GB of actual data according to GParted, and one of the drive's heads (out of 8) completely failed about midway through (after reading ~1.5TB of 00s...). So now I'm looking for a way to restrict the recovery to the allocated areas, to get the most out of what's left. I'll create another question on that subject. – GabrielB – 2019-05-26T14:26:52.593

Answers

4

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.

--attributes-only
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

Kamil Maciorowski

Posted 2019-05-26T03:33:48.287

Reputation: 38 429

1Thanks, I'll try that, it seems to be exactly what I'm looking for. – GabrielB – 2019-05-26T14:28:51.100