I want to backup the home directory of my Mac. For reasons I won't go into, using builtin Mac backup tools is not an option and the backup cannot be too large. Luckily I already have my own software to do the backup, so the first point is taken care of. For the second point, I know that the data that is important would add up to about 5 GB, which acceptable.

When I took a look at my actual home directory however, it was way too big. It turned out that ~/Library alone takes about 50 GB.

What exactly is the purpose of this directory, and what sort of files are expected to be in it? What are the consequences of excluding it from the backup?

  • As said, there is a lot of stuff in the user Library that is important and would cause grief if destroyed with no backup. I'd be very interested to know why you can't use Time Machine or a drive bigger than 5 GB.
    – benwiggy
    Aug 11 '20 at 8:20
  • @benwiggy I don't think the reason is very interesting nor relevant to the question. The point is that 50 GB is too big for my situation.
    – Donentolon
    Aug 11 '20 at 20:35
  • That's your prerogative, of course. But the best advice comes from the best understanding of the situation. It may be that there's a completely different approach that might solve your problem without such limitations.
    – benwiggy
    Aug 11 '20 at 20:43
  • Could you post a screenshot you get after you run a scan of Disk Inventory X derlien.com/downloads/index.html or any of apple.stackexchange.com/questions/5353/… or running cd ~/Library; du -hs * | sort -h
    – anki
    Aug 11 '20 at 20:47
  • 1
    @Donentolon As long as you're excluding caches and Developer folder, you'd be saving a lot of space and not losing much. Without checking which folders take the biggest space, how are you going to find out what you lose ? I don't have any interest in seeing what you have on your mac.
    – anki
    Aug 11 '20 at 21:56

The Library folder contains all the preferences set for the applications you are using, login information for Mail etc, the local mail archive, your keychain and a lot of other configuration stuff. If you are using iCloud Drive it also contains the local copy of the drive content; and backups of your iDevices in case you don‘t use iCloud backup for them.

You may be able to recover most of it in case of data loss, but some things (e.g. your keychain or any locally stored mail) will be lost.

Given that external drives and USB sticks are rather cheap nowawdays it's most probably not worth the pain to fine-tune a backup script to include just the essentials from ~/Library.

  • Re: Last paragraph -- as indicated in my question, the size is actually significant because of how the backup must be done in this particular case.
    – Donentolon
    Aug 11 '20 at 7:58
  • @Donentolon I would probably start with running cd ~/Library; du -sm *; du -sm Application\ Support/* to get a better understanding of the sizes involved. You obviously won't need logs or caches, but even within Application Support there is a mix of preferences (which you may want to keep) and cache-like stuff (e.g. Java)
    – nohillside
    Aug 11 '20 at 8:14
  • Fair enough. I actually use ncdu as it has better usability. Based on this answer, I think my solution would be to leave ~/Library out of my backups, and deal with any configuration there otherwise.
    – Donentolon
    Aug 11 '20 at 20:36
  • @Donentolon I have this issue too but you want to backup ~/Library it is difficult to recreate. But exclude the larg data e.g. Application Support/Steam
    – mmmmmm
    Aug 11 '20 at 22:31

I will add this answer to document my own workaround.

I take my backups using gtar (the tar utility from Linux; because the tar shipped with Macs is buggy) to create an archive of my ~. Since I keep everything important to me in ~, this works out.

gtar supports excluding but the implementation is a mess and took a lot of troubleshooting to figure out. It seems to depend on the version of the program, I have v1.32 and the correct syntax and order looks like gtar --exclude=${HOME}/Library --exclude=${HOME}/OtherDir -cf archive.tar ~.

This shrinks the size of my backup to a reasonable size. The drawback is that Applications like to store their settings under ~/Library, so you would have to reconfigure everything. I solve this problem by separately backing up only those configuration files that I care about. Important configs are already symlinked and moved to my dotfiles repo as described here. Since my dotfiles are not in ~/Library, they get included in the backup (in addition to also being, in effect, backed up on Github).

You must log in to answer this question.

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