There are three problems you're dealing with here:
How do you back up your Mac filesystem in such a way that you don't lose any data?
How do you make that data accessible to linux?
How do you use that data in linux?
None of these are immediate when operating between the Apple ecosystem and any other (Windows or Linux).
The reason for these difficulties is that Apple's filesystems, in order of historical introduction, HFS, HFS+ and APFS, are filesystems that use "Extended Attributes" (EA's), which include "forks."
These metadata components may not be translatable in any obvious way to another filesystem. For example, Apple FS's have as standard, two forks (though they may technically have any number). The data fork contains most of what we usually think of of file data, along with a resource fork, often but not solely used by executables. (And though that wikipedia link does not mention the resource fork in APFS, they do still exit there.) There is other metadata, including that for the Finder program and "a separate area for metadata distinct from either the data or resource fork... However, the amount of data stored here is minimal, being just the creation and modification timestamps, the file type and creator codes, fork lengths, and the file name."1
An Approach 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 HFS+ or 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 archive format that you will not be able to read under linux, which may happen if you are not using a cross-platform tool. 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 an archive format unreadable under linux. You just want an APFS filesystem, with you files copied to it.
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 metadata may have, will depend on the file. How problematic this may become for you, may not be clear until you try.
The 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; though you will still then be faced with the question of proper use of that data under linux. You may do well to consider this article, "Command Line Backup Solutions on Mac OS X," before proceeding. As discussed in that article, be careful to note that using MacOS's resource fork aware version of rsync (or tar) will produce output that is not usable by linux's version or rsync or tar!
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. The filename/._filename system for storing HFS+/APFS files to other filesystems, has a name. It is called AppleDouble format.
I am not clear if this same approach 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
Disk Archiver (dar
), 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)
I also had some discussion on these issues with the developer.
Since dar is cross-platform, you don't have to worry about the format it stores the files in, since 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. You could use APFS if you wanted, as it's also readable under linux, but that seems pointless.
Restoring to a linux disk will produce error messages when metadata can not be reproduced. You will be able to save the problematic files in a smaller archive. Whether you can explore the attributes of those failing files using linux tools, I am not yet clear.
Backing up to Any Kind of Disk Using Restic
Restic
is similarly cross-platform and available in Homebreaw, and can handle Apple disks. (Though again, they do not distinguish HFS+ from APFS.) There is a detailed bug report describing how restic
behaves when backing up HFS+, showing what it is able to handle and where it fails. Similarly to dar
, restoring to a linux disk will produce error messages when metadata can not be reproduced. Whether you will be able to manipulate or save those problematic files separately, I am not yet clear.
Here is a short description of its installation and use in MacOS, along with a scheduler.