Question

According to Apple, Time Machine removes all but one backup for every month, all but one backup for every week of the last month, and all but one backup for every day of the last week.

I have plenty of space on my NAS (about 10 TB), and I'm currently using about 1TB of space, so space is not a concern.

How would I disable this automatic removal of old backups? Or is this impossible for Time Machine and I should use an alternative program such as rsync?

Was it helpful?

Solution 2

I ended up writing a script that cancels Time Machine's operation when it goes into the "cleaning up" phase. The content is as follows:

#!/usr/local/bin/fish
while test 0=0
if tmutil status | grep -q "BackupPhase = ThinningPostBackup"
          tmutil status
    tmutil stopbackup
else
    sleep 10
end
end

Note that this script will also prevent Time Machine from cleaning incomplete backups. To clean those, first run fsck_hfs -dfy twice, the second time rebuilding the b-trees (-Race). Then move the <***.inProgress> folder to trash using /System/Library/Extensions/TMSafetyNet.kext/Contents/helpers/bypass mv <***.inProgress folder> </volumes/drive name/.Trashes/UID/. Then, empty the trash using Finder, because only Finder can deal with deleting hard-linked directories. (Backup the trash on your startup and other connected disk first if you don't want to delete those). Then, run fsck_hfs dfy again, and you're done.

Note: this procedure (mainly the fsck_hfs ones) only applies to TM sparsebundles on network drive. Network errors can cause small filesystem errors which can build up eventually. So regular fsck is important to prevent big filesystem errors, especially when you're doing something which involves a lot of filesystem modification (like deleting a ton of directory hard-links here).

Alternatively, you can also use Carbon Copy Cloner, and if you set a long time for safety net APFS snapshots, a long and more detailed period of history will be preserved.

OTHER TIPS

Time Machine Keeps Weekly Backups.

If you want to keep backups that are more regular than weekly, but less regularly than hourly then it's probably best to use a different solution. Time Machine doesn't have these settings (apparently not even in hidden settings).

Time machine keeps weekly backups as space permits. It also stores daily backups for the past month, and hourly backups for the past 24 hours.

Pros and Cons (case examples)

In the case that you create a file one day and then delete it about two days later, more than a month passes before you want to recover the file, and the weekly backup that is kept for that time period is not between the time the file was created and the time it was deleted, then a daily backup will keep the file and a weekly backup will not. This is the specific scenario where another backup solution will be desirable. However if you create a file one hour, delete it two hours later, and less than a day has passed, then Time Machine would have the file backed up, but a daily backup is unlikely to have it backed up.

I suspect that you'll find doing hourly backups with rsync will be more intensive for your computer than Time Machine's hourly backups.

Many thanks @Joy Jin. I have improved the solution by decreasing the interval from 10 seconds to 1 second to prevent cleaning backups better:

#!/usr/local/bin/fish
while test 0=0
if tmutil status | grep -q "BackupPhase = ThinningPostBackup"
    tmutil status
    tmutil stopbackup
    echo '!'
    say "Prevented cleaning Time Machine backups"
else
    echo -ne '.'
    sleep 1
end
end

It is important to create a daemon (e.g. in /System/Library/LaunchDaemons), to be run permanently.

Licensed under: CC-BY-SA with attribution
Not affiliated with apple.stackexchange
scroll top