MacOS – Put OSX under version control

backupdockermacostime-machine

I have recently learned about Docker and love their declarative approach which enables me to put everything under version control and make the whole application basically immutable.

I understand that this is a much harder task to accomplish for a full blown OS like Mac OSX.

Still, I would love to have more control over how everything runs.

I am a developer so I frequently install stuff on my machine to try out, use command line tools that download packages, etc. pp.

A recent example was that I installed a OSX Developer Beta because a sound controller was not longer working and it was already fixed in the beta version. It did fix the sound problem but introduced other problems so having the ability to "easily" roll back to a previous state would have been really handy.

So what's the best approach to bring my OSX from a clean blank install to a desired state and from there on "put it under version control" so that I can easily try out new stuff but roll it back at any point in time?

Maybe even incorporating the idea of "sandboxing" stuff, for example when a family member or friend asks lend my MacBook without me having control on which websites they surf and what they may download and install.

A third thing that would be nice to have if I could share those states between two machines (for example when I both have a macbook and iMac)

I know that Time Machine is able to do some of this this stuff, but maybe there is something like "Docker" which brings this to a whole other level.

To be honest I have never really used time machine because I was frequently traveling and it was more convenient to backup files into the cloud instead of needing an external hard drive for time machine backups. This situation has changed as I am now planning to get a NAS where time machine backups could be done.

Maybe somebody knows other best practices or has a good article that answers those questions.

Thanks

Best Answer

You can create APFS snapshots of your disk using tmutil.

tmutil localsnapshot

I am not aware of how long these snapshots are kept for. They are marked as purgeable space so macOS can remove them at will. There may be a way to mark snapshots to be kept without being automatically removed.

You can list existing snapshots with

tmutil listlocalsnapshots /

These snapshots can be restored from Recovery:

Select a Local Snapshot

Screenshot from https://derflounder.wordpress.com/2017/11/02/apple-software-updates-creating-apfs-snapshots-on-macos-high-sierra/ which has more details about how macOS creates snapshots automatically on macOS updates.