Contribute
Register

EFIClone - automatic backup of the EFI partition

Another way: compress the EFI folder and checksum it, then compare it to your last backup. If they differ keep the new one.

Yeah, I already have a checksum routine running for the main backup - I'll have to play with it and see the pros and cons of the checksum vs. rsync. I think rsync dry-run will be cleaner, but we'll see
 
Just a quick note here - mostly to remind myself - I have found the way to determine with 100% certainty which EFI partition was used to boot the machine for the current session (not just which macOS partition has is the active boot volume)... bdmesg displays the Clover bootleg and the UUID of the EFI partition used to load clover and kick off the startup is listed in this log - and is also accessible within diskutil. I will add a check to that to ensure that the destination EFI partition can never be the current boot partition for safety. Because of the dis-association between the EFI partition and the macOS partition, this was my biggest concern bit now I have a way to ensure the script won't ever wipe out the current boot EFI partition.
 
I recognize that you could screw something up un /L/E or /S/L/E, but I'm not ready to go there. Changing things in Clover/EFI is what most often screws me up.

Anyone care to comment?[/QUOTE]

I screw up my EFI on a regular basis, I will then copy the EFI of my backup. But yeah, if you don't have a backup, or you changed 3 things and the first 2 were fine, this would come in handy.
 
I, personally, don't make enough changes to my EFI folder to need automated/scheduled backups. For me, just automating the backup when I make a CCC clone is enough.

Also, I use CCC to clone to a USB drive which isn't always plugged in, so scheduling wouldn't work for me anyway.
 
I, personally, don't make enough changes to my EFI folder to need automated/scheduled backups. For me, just automating the backup when I make a CCC clone is enough.

Also, I use CCC to clone to a USB drive which isn't always plugged in, so scheduling wouldn't work for me anyway.

It is definitely not an option for everybody so I think that one will be a separate script to archive your working EFI partition as a scheduled task.

Just to clarify, though, the idea I have for that one is that it will create an automated backup of the current startup EFI partition to a folder on the current macOS startup partition (or potentially to a specific user-defined folder on ANY partition).

The idea in my mind is to always keep a valid EFI backup in a location on each macOS partition so that you can easily roll back to a point-in-time if you accidentally screw it up and didn't take an intentional backup with CCC or SD!.

I believe I will create this script, but it will be after some of the upcoming enhancements to the safety and security of the current EFIClone.sh
 
Updated to 0.1beta3

Two significant changes:

-Added detection of the EFI partition that was used to boot the current session of the mac and prevent the script from modifying data if that matches the destination EFI partition that was calculated. I will not delete or modify the current boot EFI - I think it is too dangerous.

-Changed to use rsync to do all modifications on the destination partition. rsync will delete files that have been removed from the source on the destination. This change also allows me to put the complete manifest of what rsync WOULD do into the log file by using the dry-run option.
 
I've added a new script that will function to take an automatic snapshot of your latest working EFI partition configuration after each successful boot of your hackintosh.

This script does the following:

  1. At each boot, it mounts the EFI partition on the physical disk that is the same where your macOS boot partition resides
  2. It compares the contents of the EFI partition to the contents of the most recent "snapshot" copy of the EFI partition to see if anything has changed.
  3. If nothing has changed, it exits - only logging the fact that the script ran and that it found no changes
  4. If something has changed between the current EFI partition and the current "snapshot", it does the following:
    • Create an archive of the previous known good EFI "snapshot" and label it with a date/timestamp so that you have a history of the good EFI configurations that booted your computer
    • Copy the new "known good" contents of the EFI partition to the snapshot so that you have a good, quick recovery copy
The idea of this script is twofold. First, if you do something to your EFI partition that corrupts it, you can simply boot from any emergency EFI boot USB drive and re-copy the contents of the EFICurrent folder to the EFI partition on your boot drive and return to the last known good configuration.

Secondly, the script will keep an archive of good configurations of your EFI partition so that if you make a tweak or other change to your EFI partition that does NOT prevent booting, but that changes something else which you later find undesirable, you will have an easy way to restore whatever it is in your EFI partition that you changed.

Installation and configuration is fairly straightforward.

1. Create a directory in the root of your macOS startup volume named EFISystemRestore
2. Copy the EFISystemRestore_backup.sh file to the /EFISystemRestore/ folder you just created
3. copy com.hackintosh.EFISystemRestoreBackup.plist to /Library/LaunchDaemons/
4. Open a terminal window and key in the following two commands:

sudo launchctl load -w /Library/LaunchDaemons/com.hackintosh.EFISystemRestoreBackup.plist
sudo chown root /Library/LaunchDaemons/com.hackintosh.EFISystemRestoreBackup.plist
The script will create a log of its activity in the /EFISystemRestore/ folder.

Since this script is non-destructive to the current good EFI partition, I am releasing it sooner rather than later. If you experience any problems, please feel free to share experiences or questions and upload logs for me to review.

Enjoy...
 
Since this script is non-destructive to the current good EFI partition, I am releasing it sooner rather than later. If you experience any problems, please feel free to share experiences or questions and upload logs for me to review.

Enjoy...

@wombat94 Many thanks for both these scripts - the first one used with CCC works perfectly for me but I appear to have an issue with EFISystemRestore.

I installed it as per the instructions and then re-booted
The first thing I noticed was that after boot my EFI partition was mounted
I then checked and could find no backup of the EFI partition
I read the log from the EFISystemRestore folder (which I am attaching) and noticed there was no successful completion line at the end which I sort of expected.
I thought maybe something had gone wrong when I went through the instructions so I issued these commands again in

sudo launchctl load -w /Library/LaunchDaemons/com.hackintosh.EFISystemRestoreBackup.plist
sudo chown root /Library/LaunchDaemons/com.hackintosh.EFISystemRestoreBackup.plist
I then re-booted again and had the same result - no sign of a backup

what do you think?
 

Attachments

  • Archive.zip
    64.5 KB · Views: 227
Back
Top