2

I manage a few Linux servers, and in a few of them, if I want to perform backups, I can leverage filesystem snapshots. I.e. I can create a snapshot and then clone it to a second machine, thus ensuring all data is safe.

On macOS, direct snapshot cloning is not possible. However, according to guides I've seen online, it should be possible to:

  1. Create a snapshot of the root folder /
  2. Mount that snapshot as read-only
  3. Copy the files from the mount point, for example, using rsync

This is just like Carbon Copy Cloner and Active Backup for Business (from Synology), which both take a snapshot first and then copy the contents from it during the backup.

As far as I understand, it should be as simple as:

$ tmutil localsnapshot /
$ tmutil listlocalsnapshots / # Ex: latest snapshot = com.apple.TimeMachine.2024-06-12-114527.local
$ mount_apfs -s com.apple.TimeMachine.2024-06-12-114527.local / /private/tmp/rsync-apfs # folder /private/tmp/rsync-apfs created by me
$ # ...access /private/tmp/rsync-apfs and copy contents using rsync

Unfortunately, mount_apfs gives the following error:

mount_apfs: volume could not be mounted: Resource busy

I also saw here a variation of these commands where "/" is substituted with "/System/Volumes/Data", in which case the error I get is:

mount_apfs: volume could not be mounted: Operation not permitted

Running with sudo produces the same results. What is the issue here? Searching on google for these two errors did not produce any solutions.

Edit: In case it is relevant, I'm on macOS Ventura 13.6.4

2
  • Note: I'm aware of this apple.stackexchange.com/questions/471912/… but I still have the problem described above
    – Alex
    Commented Jun 12 at 10:11
  • The APFS internals change regularly. That’s why I prefer letting SD or CCC manage making this all work as Apple upgrades and changes things over time. It’s a great question, so let’s see what people have to say other than my answer to outsource your development and testing efforts here.
    – bmike
    Commented Jun 12 at 10:47

2 Answers 2

4

What you describe is possible, implemented and already done with a commercial product SuperDuper

My thinking is:

  • you don’t want rsync for this (use git if you have text and code files to save or use a complete tool if you want full Mac file backup)
  • Handling the mount syntax is tricky (and I hope an expert comes and teaches us both how to script what you envision)
  • you do want asr for copying the files and all metadata and manner of links in general
  • hire this out to an expert rather than spending your valuable time crafting a DIY solution.
  • The time you spend getting up to speed with Dave Nanian’s (or Mike Bombich’s) tool will be so much less than trying to catch up to his skill in finessing the under and undocumented by Apple apfs workings. (Thank goodness for people like Bombich, Nanian and Oakley for their work documenting and extending backup of APFS files)
  • Carbon Copy Cloner is also amazing and worth an evaluation, but if you’re skilled at scripting and shell and rsync, I’d start with SD over CCC personally.

Granted your requirement,

"I want to copy files over a high latency network connection (halfway around the world to my own self hosted NAS over my own private VPN). CCC only supports SMB for copying over the network and SMB is shit slow, whereas rsync maxes out the connection bandwidth."

and since macOS's APFS snapshots seem like a moving target in terms of being able to utilize them how you like, why not use a backup tool (e.g. Carbon Copy Cloner, SuperDuper) to create a backup of your own (e.g. a sparsebundle), and then rsync to sync it how you like? Some tools (CCC included) also support pre- and post- job scripting, which might be a welcome feature for you.

15
  • I agree with your suggestions, but for multiple reasons, I'd like to use rsync to perform the actual copy. Therefore, either SD/CCC support rsync, and in that case I'm happy to use them (yes, letting them figure APFS out is much better, not doubt), or I have to roll my own solution. I use CCC regularly for other stuff, AFAIK rsync is not supported there. I've heard of SD but I'll need to investigate if it supports copying over rsync.
    – Alex
    Commented Jun 12 at 11:39
  • I would use SD to automate copying files off APFS snapshot to a holding volume of your choose be and then rsync away. There’s huge value in building your own toolchain in many cases - learning is just one valid one.
    – bmike
    Commented Jun 12 at 14:19
  • Unfortunately that isn't possible because an external holding volume isn't always available, and there isn't enough space for an internal holding volume.
    – Alex
    Commented Jun 12 at 16:46
  • Are these Mac minis in a server environment?
    – bmike
    Commented Jun 12 at 16:53
  • 1
    Instead of trying to move APFS snapshots, why not have CCC create a sparse bundle and rsync that instead?
    – Harv
    Commented Jun 19 at 10:17
0

For anyone stumbling upon this in the future, I was able to solve my own problem. CCC 7 includes the capability to create, mount and delete snapshots in its command-line tool (for this I had to update from CCC 6, which is what I had). Using CCC 7 I wrote a script that creates the snapshot, mounts the snapshot, uses rsync to copy the data from the snapshot volume, then unmounts and deletes the snapshot.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .