The problem you are faced with is that Apple's HFS+ and APFS filesystems are very complicated, with each file being a complex data structure composed of a so-called "data fork," "resource fork," and Finder metadata. For APFS, there are also apparently encryption keys in there. The standard linux backup tools, eg. rsync
, will not recognize these various components of your files.
A Solution that Puts Off Part of the Problem by Backing up to an Apple Formatted Disk
One approach is to backup your present files using some Mac solution like TimeMachine, which will copy to an APFS filesystem. When the time comes to move to linux, you will have your files and be able to read them (though not write) using linux's hfsutils
, hfsprogs
and hfsplus
or, apfs-fuse
, apfsprogs-git
& linux-apfs-dkms-git
.
Later You Will Want to Use Your Files on Linux
Of course, for the purposes of your question you will in addition want to know how to represent all of your files in a usable way on some linux FS. Clearly the Finder data is of no use, and you will have to lose HFS+'s "birthtime" attribute (see below), because that is not tracked in Linux. The data fork contains the bulk of the information, but what relevance the resource fork and some of the other APFS metadata may have, I am not clear.
The two following approaches will allow you to save all of your MacOS data to a linux formatted disk, but you will still be faced with the later question of proper use of that data under linux.
Backing up to a linux disk with rsync
There is a project called rsync+hfsmode
that will handle backing up to linux formatted disks properly, at least for HFS+, but it does it by creating two files on the backup drive: filename
, containing the data fork, and ._filename
containing the resource fork and Finder metadata. Furthermore, when copying back to an HFS+ disk, a second step is needed to reconstitute those two files into a proper HFS+ data structure. You can see a more complete discussion at the project page. I am not clear if this will work for APFS, though the question asked on the Apple Developer Forum was responded to with silence; so perhaps not.
Backing up to any kind of disk with dar
It appears that dar
(Disk Archiver), which is available in Homebrew, can handle the unique characteristics of MacOS filesystems (they do not distinguish between HFS+ and APFS, but say they can handle extended attributes, including file forks). According to their Features page.
EXTENDED ATTRIBUTES (EA) references: MacOS X FILE FORKS / ACL Dar is able to save and restore EA, all or just those matching a given pattern.
File Forks (MacOS X) are implemented over EA as well as Linux's ACL, they are thus transparently saved, tested, compared and restored by dar. Note that ACL under MacOS seem to not rely on EA, thus while they are marginally used they are ignored by dar.
FILESYSTEM SPECIFIC ATTRIBUTES (FSA) references: MacOSX/FreeBSD Birthdate, Linux FS attributes
Since release 2.5.0 dar is able to take care of filesystem specific attributes. Those are grouped by family strongly linked to the filesystem they have been read from, but perpendicularly each FSA is designated also by a function. This way it is possible to translate FSA from a filesystem into another filesystem when there is a equivalency in role.
currently two families are present: HFS+ family contains only one function : the birthtime. In addition to ctime, mtime and atime, dar can backup, compare and restore all four dates of a given inode (well, ctime is not possible to restore)
So far I have not found other solutions. I will add them here if I do.