I am on trying to archive a directory (a Time Machine backup) using:

tar -czf /Volumes/My\ Drive/archive.tar.gz my_directory

The archive process is going on at the moment. I am monitoring the archive process. The entire HDD has 167GB used space, the size of directory I am trying to archive is 160GB. But the archive has already gone up to 170GB now.

I am not sure why gzipped archive size is going bigger than the actual drive size, let alone the directory size that I am trying to archive.

I am using MacOS 10.13.

  • 1
    What kinds of files are in the directory? Are they already compressed? – Kusalananda Oct 22 '17 at 13:03
  • @Kusalananda It's actually the timemachine backup, so they may contain some zip archive but hardly 5% of files are zip archives. – Aniruddh Joshi Oct 22 '17 at 13:18
  • You may be dealing with all compressed files, even if they don't have an explicit filename extension. Just repeat the process again without compression and compare the results. Compressing files that cannot be compressed may create more metadata, as well as the fastball may be storing the files less efficiently than the original filesystem, leading to bigger file sizes. – Zip Oct 22 '17 at 13:55

Apple's Time Machine software makes heavy use of hard-linked directories. The HFS+ filesystem on macOS is one of the few Unix filesystems that support hard links to directories.

I'm assuming that tar can't properly handle these directories has being hard-linked and will duplicate their contents, leading to the archive being multiple times bigger than the Time Machine directories.

You will get a similar effect when copying hard-linked files with a utility that is not aware of the files having multiple names.

  • So a simple tar archive is the solution here? Should I skip any compression? – Aniruddh Joshi Oct 22 '17 at 14:11
  • Or May be a compressed DMG? – Aniruddh Joshi Oct 22 '17 at 14:13
  • @AniruddhJoshi No, don't make a tar archive of it at all, it will not work. It's not the compression that is the problem. Instead duplicate the volume somehow (I'm unaware of how to do this on macOS). – Kusalananda Oct 22 '17 at 14:13
  • Alright I will try creating a DMG image. – Aniruddh Joshi Oct 22 '17 at 14:14
  • @AniruddhJoshi Personally, I would just swap out the drive. You also have not mentioned the purpose of this exercise... – Kusalananda Oct 22 '17 at 14:15

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.