Skip to main content
15 of 25
added 1157 characters in body
Diagon
  • 128
  • 6

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 "data fork," containing most of what we think of as the file's content, but in addition Extended Attributes like a "resource fork," and Finder metadata. The resource fork can be quite large, and for APFS it can apparently include encryption keys. 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 that will keep copies of your files on 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(installation tutorial), apfsprogs-git & linux-apfs-dkms-git.

Make sure that your backup system does not store your files in some proprietary format that you will not be able to read under linux. For-fee solutions include Get Backup Pro and CronoSync Express. While the first would be a true backup (keeping historical copies of files), the second could be either a backup or a simple mirror. It is possible that TimeMachine might also work, though you will have to confirm that it doesn't use a format unreadable under linux. You just want an APFS filesystem, with you files copied to it. For free solutions which are also cross-platform, read about dar and restic, below.

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 filesystem. 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 instead to a linux formatted disk, thereby doing without Mac Backup Software or TimeMachine, etc., and also dispensing with the later need to read an Apple disk under linux, but you will still then be faced with the 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 cross-platform and 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)

Since dar is cross-platform, you don't have to worry about the format it stores the files in. You'll also be able to install dar on linux, when it is time to move there. In this case it probably makes sense to format your backup disk as some linux filesystem, but you could use APFS if you wanted, as it's also readable under linux.

Backing up to Any Kind of Disk Using Restic

Restic is similarly cross-platform and available in Homebreaw. I'm not finding any detailed description of its handling of extended attributes, but many people are using it on their Mac's, and it says in the docs:

Restic saves and restores most default attributes, including extended attributes like ACLs.

Here is a short description of its installation and use in MacOS, along with a scheduler.

Diagon
  • 128
  • 6