APFS Bootable Clone With Command Line

After multiple trial and error attempts, we finally mastered APFS and are ready to share the knowledge on creating APFS bootable backup with macOS command line. Having such copy on an external drive is rather useful in case something disastrous happens to your local disk, you will have an exact copy of the disk that can be connected externally to your Mac and boot it up. Clone copy of your disk will protect you against any physical or software damage to your computer and system disk, by preserving all the essential files and data.

All of the commands below should be used in Terminal app on macOS 10.13 or later. Highlighted in bold parts should be replaced with your own respective volume name, disk ID, etc.

Using Disk Utility app create an APFS volume on your external disk. Make sure that your external disk use GUID partition scheme. It’s also important that created APFS volume size is equal or bigger than the source system volume. Let's name the external disk volume as BackupClone.

Creating an APFS volume

Activate on-disk ownership on your disk volume with the help of vsdbutil tool. Copy/paste the string below into Terminal, change BackupClone part to your external disk volume name and press return:

sudo vsdbutil -a /Volumes/BackupClone

Create full copy of the source system volume on BackupClone volume with the help of rsync tool:

sudo rsync -xrlptgoEvHS --progress --delete / /Volumes/BackupClone

Now we need to make our clone bootable. To do this we need to create a new Preboot volume in APFS container that includes BackupClone and copy system files from source Preboot volume in there.

Check the current situation with all your volumes:

diskutil list

As a result we see that MyDisk (disk1s1) is the source, and BackupClone (disk3s1) is our clone copy destination:

Terminal window screenshot

Create Preboot volume in APFS container disk3 that includes BackupClone:

diskutil apfs addVolume disk3 apfs Preboot -role B

In the new Preboot volume let's create a folder, name the folder exactly as UUID of your volume BackupClone (disk3s1).

UUID can be obtained with diskutil:

diskutil info disk3s1 | grep "Volume UUID"

Result will be like this, but with a different UUID value:

Volume UUID screenshot 1

Copy/paste this UUID to create a folder on Preboot volume:

mkdir /Volumes/Preboot/A579A99E-9795-4086-890E-04E2112D1E78

Now mount the source Preboot volume:

diskutil mount disk1s2

Obtain UUID of the source volume and copy system files from source volume to external Preboot volume:

diskutil info disk1s1 | grep "Volume UUID"

Result will be like this, but with a different UUID value:

Volume UUID screenshot 2

Copy files using rsync tool:

sudo rsync -xrlptgoEvHS --progress --delete /Volumes/Preboot\ 1/CD9E8D34-F576-3F9B-AF7C-217C860721F4/ /Volumes/Preboot/A579A99E-9795-4086-890E-04E2112D1E78

Unmount Preboot volumes one by one:

diskutil unmount disk1s2
diskutil unmount disk3s2

Run command updatePreboot for your BackupClone (disk3s1):

diskutil apfs updatePreboot disk3s1

Specify the path to boot files folder on your clone volume:

sudo bless --folder /Volumes/BackupClone/System/Library/CoreServices --bootefi

Update dyld's shared cache on clone volume using update_dyld_shared_cache tool:

sudo update_dyld_shared_cache -root /Volumes/BackupClone -force

In System Preferences open Startup Disk tab, then select BackupClone and press Restart button. Your computer will restart and boot up from created BackupClone volume.

Now you successfully created a bootable clone of your APFS disk volume. The next time you need to boot up your Mac from the clone, connect the external drive and start your Mac holding Option (Alt) key, until boot disk selection appears.

If you have questions or want to comment on the article, contact our Support Team.

If you don’t want to spend time on all of the steps above, or you want to create clone backups on a regular basis, try Get Backup Pro. Beyond that, Get Backup Pro will offer:

Incremental and compressed backups
Incremental and compressed backups
Schedule your projects
Schedule your projects
Encrypted backups
Encrypted backups
Bootable clones
Bootable clones
Synchronize files and folders
Synchronize files and folders
Backup to External or Network Volumes
Backup to External or Network Volumes