I am currently trying to use dd to backup and copy the Backups.db folder (which contains all Time Machine Backups for Mac OS) in my external hard drive. The issue is that my hard drive does not only contain the Backups.db folder, rather it also contains other folders and files at the top level. If I use dd on the device, it will copy the other folders and files as well. I need to use something like dd because of the hard links present in the Backups.db folder, which makes something like cp or tar not work.

At this point, should I copy out the other top level folders so that the external drive only contains the Backups.db folder? Or is there a more efficient way for this? I am asking as I know dd can only be used on devices, after unmounting.

  • Please specify that you are using MacOS in title. I was thinking all files in Linux are hard links, just sometimes multiple files pointing to same inode. Oct 25 '20 at 2:22
  • 2
    @Ding-YiChen tags should not be added to titles. It is clear enough that this is about macOS (where all files are also hard links, just the same as Linux).
    – OrangeDog
    Oct 25 '20 at 14:44
  • The GNU versions of cp and tar (installed via homebrew) can preserve hardlinks and permissions.
    – OrangeDog
    Oct 25 '20 at 19:47
  • 2
    Your using the wrong tool my friend, perhaps rsync would be more appropriate. Oct 25 '20 at 20:20
  • reminder dd is known as disk destroyer. be very careful with it.
    – qwr
    Oct 25 '20 at 23:04

To answer the question, no it is not feasible.

dd operates directly on the blocks of a device, and has no understanding of file systems, folder, or files. A single directory will almost never be stored in a single contiguous region, and even single files may be broken up a spread around. Moreover, you cannot copy only bits of a filesystem to save space and expect it to still work, because all the indexes and offsets still need to line up.

The work required to do such a thing involves writing basically a whole filesystem driver to understand how everything is located and how it can be changed, and performing it with multiple dd calls. There's no point when this already exists and can be done with the normal file utilities like GNU cp, tar, and rsync.

  • 1
    To be precise, dd will operate directly on the blocks of a device or file. You can copy a file with dd. Copying a hierarchy of files, though, is indeed not something dd can do, unless all of that is within a single device or file and one wants to copy the whole thing, not parts of it.
    – jcaron
    Oct 25 '20 at 22:14
  • Is there any difference between cp and dd when used to copy a simple file?
    – Vilx-
    Oct 25 '20 at 22:58
  • 1
    @Vilx- dd can only copy the data, not the metadata (its name, permissions, etc,)
    – OrangeDog
    Oct 26 '20 at 9:35

I'd always say, don't try to do from the command line something that can be easily achieved using the GUI.

Copied from How to copy Mac Time Machine from on drive to another
Finder knows how to do this, almost nothing else does.

Hard links &/or permissions are the downfall usually.
Don't attempt to manually trim it as part of the copy process, just copy the whole lot. If you need to trim by size or date, do it separately.

Apple guide on copying - Transfer Time Machine backups from one backup disk to another

In brief:
Format HFS+
Set correct permissions system rw wheel rw everyone r
Turn off Time Machine
Drag the entire Backups.backupdb folder to the new drive.

Ask Different guide on trimming for size - Remove unnecessary backups from TimeMachine to get space

  • are you aware of any ways I can archive the entire Backups.db folder, upload it online, then still be able to run it like nothing happened? thanks
    – user321627
    Oct 25 '20 at 19:26
  • I'd say it would be impossible. No online structure is going to be able to translate the hard links. You'd end up with a 1TB drive taking up 50TB online.
    – Tetsujin
    Oct 25 '20 at 19:30
  • @user321627 GNU tar can preserve hardlinks, and online storage will not fiddle with it.
    – OrangeDog
    Oct 25 '20 at 19:47
  • @OrangeDog - apple.stackexchange.com/questions/400768/… would agree with you, but no-one ever came back to say it worked.This is now getting so far away from the OP [& my answer] that it ought to be a new question.
    – Tetsujin
    Oct 25 '20 at 19:52
  • @Tetsujin Well, any question would be a duplicate of that one.
    – OrangeDog
    Oct 26 '20 at 9:37

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.