Time Machine: backup file size limit

    Having tormented for many hours in search of a solution, I decided to share the method I found with Habr’s readers.

    Time Machine stores all backups in a “growing disk image package”, the physical size of which in the placement takes up exactly as much space as the data in it. This approach saves us from having to divide the storage into partitions - one for different purposes - all image packages are stored on the same physical partition, consuming megabytes and gigabytes only if necessary. It is convenient when you do not know in advance what size to allocate for a particular task.

    A useful feature of a “growing disk image package” is to set a limit on its maximum size. At the first start, Time Machine creates an image package with a restriction equal to the entire capacity of the partition on which it will be located. And with the exhaustion of free space, old backups simply begin to be deleted. Prior to Mac OS X 10.6.3, there was a way to change this restriction using the hdiutil utility . For example, the following line sets a limit on the maximum size of an image package equal to 500 GB:

    hdiutil resize -size 500G -shrinkonly /Volumes/Data/macbook.sparsebundle

    However, with the 10.6.3 update, Time Machine began to automatically change the image package parameters each time it was started, restoring the size of the restriction to the default value (that is, to the maximum) if it was changed or the media capacity changed.

    There is still no official solution to the problem from Apple. The solution is another trick - to block the change in the parameters of the image package after setting the necessary size limit for it.

    It is worth noting that the image settings are stored in the image itself in the Info.plist and Info.bckup files . And in order to block parameter changes, you must block the change of these files. I’ll say right away that a simple write ban with chmoddoes not work. But another way works (10.8.2) - blocking files using the SetFile utility :

    SetFile -a L /Volumes/Data/macbook.sparsebundle/Info.*

    After executing this command, Time Machine will no longer be able to change the image parameters:

    SetFile is not included in the standard set of Mac OS X utilities and is installed by installing the Xcode application and the additional Command Line Tools component:

    To be able to change the image parameters again, it is necessary to unlock ( we use the same arguments with the only difference being that instead of the capital letter “L” we put its capital version - “l”):

    SetFile -a l /Volumes/Data/macbook.sparsebundle/Info.*

    PS: A method was found while studying this discussion .

    Also popular now: