Follow By Email

Wednesday, March 1, 2023

[New post] How does Time Machine make a backup?

Site logo image hoakley posted: "Time Machine has undergone major changes over the last few years, both to make efficient backups from APFS, and to support backups stored on APFS volumes. It has been a couple of years since I last examined how Time Machine makes backups to APFS: this art" The Eclectic Light Company

How does Time Machine make a backup?

hoakley

Mar 1

Time Machine has undergone major changes over the last few years, both to make efficient backups from APFS, and to support backups stored on APFS volumes. It has been a couple of years since I last examined how Time Machine makes backups to APFS: this article steps through what happens when Ventura 13.2.1 makes an automatic hourly backup of an APFS volume to APFS backup storage, Time Machine to APFS, or TMA.

Scheduling

Automatic TMA backups aren't run at fixed times, but are scheduled and dispatched by the DAS-CTS subsystems so that backups are only made when conditions are suitable. One simple rule applied is that the first backup made after a Mac starts up is delayed for five minutes, to allow other processes such as Spotlight indexing checks to be run first. DAS-CTS is explained in fuller detail in this article, using TMA as an example.

Should regular automatic backups fail, the first task in discovering where the problem lies is to check DAS-CTS scheduling. Although normally very reliable, failure of those subsystems will prevent backups from taking place.

Setting up the backup

Once backupd has been told to make a backup, it announces
Starting automatic backup
in the log and starts checking the resources it needs to do that. First is the mount point of the backup storage, referred to as the target volume. If that's not available, then TMA will normally still make and maintain local snapshots of the volumes to be backed up. It's at this stage that the next of multiple target volumes is identified when backups are being rotated between different destinations.

In more recent versions of macOS, file write performance to the target volume is then measured by writing a single 50 MB test file, and concurrently writing 500 files of 4 KB size to the volume. These tests are also performed when backing up to network storage, when they may fail altogether, but TMA appears to proceed regardless of the results. However, those are written to the log, where they are a useful reference in the event of performance problems.

The next issue for TMA to tackle is whether the backup to be used is inherited using machine store inheritance; normally that shouldn't be needed, allowing TMA to proceed to snapshot maintenance.

tmbackupapfsvent1

Snapshots

Before making any snapshots for this backup, TMA performs housekeeping on its own previous snapshots, both on each volume being backed up, and on the target volume (backup storage). The rule it applies is inflexible: it deletes any local snapshots (on a volume being backed up) that are more than 24 hours old, unless it's the last snapshot on that volume, which it retains for this backup. Even so, TMA snapshots can become orphaned and left indefinitely, for the user to spot and delete manually. Although uncommon, this can occur when Macs are unable to make full backups because they're disconnected from their backup storage for more than 24 hours at a time.

Maintenance of snapshots on backup storage is more complicated and currently opaque.

With expired snapshots deleted, TMA then makes a fresh snapshot on every volume that it's going to back up, that's stored locally to that volume, and declared as the stable snapshot for the purpose of this backup. Because APFS can only make whole-volume snapshots, this means that if TMA is only going to back up a single folder on a volume, a snapshot is still made of the whole of that volume, which includes all the files and folders normally excluded from backups, and those excluded by the user in Time Machine's settings.

TMA then mounts the stable snapshots just made, and the last snapshots, termed reference snapshots, ready to start the backup process. These are mounted in the path /Volumes/com.apple.TimeMachine.localsnapshots/Backups.backupdb/[computer name]/[date time]/[volume name]

Determining what to back up

TMA next has the task of deciding how it's going to work out what needs to be backed up on each source volume. Choices may now include:

  • collecting events using the FSEvents database stored on that volume, recording all file system events;
  • full file list, used when this is the first backup made of that volume;
  • a deep scan of all items modified since the last backup, when no usable FSEvents database can be found;
  • calculating a snapshot delta, the differences between the stable and reference snapshots.

Snapshot deltas were first choice in the past, but TMA has returned to preferring FSEvents when possible, for second and subsequent backups of a volume.

tmbackupapfsvent2

Once its strategy has been determined, TMA uses that method to arrive at and declare what this backup will contain, and writes a detailed summary into the log. This also contains summary figures for the folders containing most of the changes to be backed up. If you're ever unsure of where much of your Mac's backups are originating, these are useful figures.

Backing up

TMA examines existing data in the backup to be 'propagated', so sparing unnecessary copying of duplicate data, and arrives at an estimate of how long copying is likely to take. While that's going on, Spotlight performs indexing. In previous versions of TMA, the log contained a clear statement of the free space remaining on the target volume (backup storage), and the decision that was sufficient to contain the backup before any copying started. That no longer appears in the log, although that check is still made.

During copying, periodic reports are made in the log providing details of progress. During long backups, these reports provide invaluable information as to what is taking the time. Once copying has completed for each volume being backed up, this is declared and summary figures given for creation of that backup. This breaks down the numbers and sizes of items added, how many were actually copied, cloned, etc.

Final checks and maintenance

Once backing up has completed, the backup and local snapshots are unmounted. The last of those local snapshots is then marked as the reference snapshot for the next backup, and TMA writes an overall result to the log. This does record free space left on backup storage, together with other useful summary figures for that backup.

tmbackupapfsvent3

Temporary space used on backup storage is then freed. This is referred to as an incomplete backup in the log, so may appear confusing. After that, TMA declares that backup as an APFS snapshot (on backup storage, not a local snapshot), and writes a summary of what it holds on backup storage, for example
59 backups: 2022-03-30-170453 to 2022-04-15-115414 (1hr,4d,1wk,14m,39yr) MĪ”: 984.1 MB
giving the number of backups, their date range, intervals between them, and the average size of each over that period.

Finally, the backup is declared complete, and backupd's XPC communications cease until the next backup is started.

Variants

The TMA backup described above is typical for an hourly automatic backup dispatched by DAS-CTS. Backups run by other means, including manual backups and those scheduled as launchd tasks, differ in various respects, and those performed to network storage also differ in their details. The summary diagram below integrates each of the stages shown above.

tmbackupapfsvent

While my free T2M2 app gives basic information to enable you to monitor and check backups, and supports a wide range of versions of macOS and HFS+ backups, you can get full details using the Time Machine log window feature in my free Mints.

Comment
Like
Tip icon image You can also reply to this email to leave a comment.

Unsubscribe to no longer receive posts from The Eclectic Light Company.
Change your email settings at manage subscriptions.

Trouble clicking? Copy and paste this URL into your browser:
http://eclecticlight.co/2023/03/01/how-does-time-machine-make-a-backup/

WordPress.com and Jetpack Logos

Get the Jetpack app to use Reader anywhere, anytime

Follow your favorite sites, save posts to read later, and get real-time notifications for likes and comments.

Download Jetpack on Google Play Download Jetpack from the App Store
WordPress.com on Twitter WordPress.com on Facebook WordPress.com on Instagram WordPress.com on YouTube
WordPress.com Logo and Wordmark title=

Learn how to build your website with our video tutorials on YouTube.


Automattic, Inc. - 60 29th St. #343, San Francisco, CA 94110  

at March 01, 2023
Email ThisBlogThis!Share to XShare to FacebookShare to Pinterest

No comments:

Post a Comment

Newer Post Older Post Home
Subscribe to: Post Comments (Atom)

[New post] Godzilla Library Edition by James Stokoe, John Layman, Chris Mowry, Alberto Ponticelli, Dean Haspiel

...

  • Open for a sneak peek inside August's box šŸ‘€
    Spoiler alert... ...
  • [New post] Everyone Wants to Be a Cat
    Donna...
  • Your Ambitious Menu: 5 recipes to cook this week
    New on Ambitious Kitchen ...

Search This Blog

  • Home

About Me

PH News Net
View my complete profile

Report Abuse

Labels

  • 【ANDROID STUDIO】Data Binding
  • 【ANDROID STUDIO】Data Binding Show or Hide Progressbar
  • 【ANDROID STUDIO】Data Binding with object
  • 【ANDROID STUDIO】Live Data
  • 【ANDROID STUDIO】Live Data with Data Binding
  • 【ANDROID STUDIO】View Model
  • 【ANDROID STUDIO】ViewModel Data Binding
  • 【ANDROID STUDIO】ViewModel Data Binding Factory
  • 【FLUTTER ANDROID STUDIO and IOS】Common Weight and Mass Conversions
  • 【FLUTTER ANDROID STUDIO and IOS】custom lite rolling switch
  • 【FLUTTER ANDROID STUDIO and IOS】Managing State
  • 【FLUTTER ANDROID STUDIO and IOS】Simple Stopwatch
  • 【FLUTTER ANDROID STUDIO and IOS】Specify Height and Width in Percent with respect to the screen
  • 【FLUTTER ANDROID STUDIO and IOS】tab key or shift focus to next text field
  • 【FLUTTER ANDROID STUDIO and IOS】Weight Convert
  • 【GAMEMAKER】Display
  • 【GAMEMAKER】Draw Name
  • 【GAMEMAKER】enemy fire continously
  • 【GAMEMAKER】Energy
  • 【GAMEMAKER】Explosion
  • 【GAMEMAKER】Health Bar
  • 【GAMEMAKER】Hearts
  • 【GAMEMAKER】Highscore
  • 【GAMEMAKER】Horizontal Shooter
  • 【GAMEMAKER】Inventory
  • 【GAMEMAKER】keep the player facing the mouse pointer
  • 【GAMEMAKER】one way to do a fog of war
  • 【JAVASCRIPT】implements draggable progress bar
  • 【JAVASCRIPT】Math Quiz GAME export CSV
  • 【LARAVEL】PHPWord pass dynamic values when export to ms docx and download using PHPWord
  • 【PYTHON OPENCV】Image classification in Keras using several models for image classification with weights trained on ImageNet
  • 【PYTHON PYTORCH】metric classification accuracy
  • 【PYTHON PYTORCH】metric classification report
  • 【PYTHON】algorithm compare all classification models
  • 【PYTHON】algorithm evaluation k fold cross validation
  • 【PYTHON】leave one out cross validation
  • 【PYTHON】metric confusion
  • 【PYTHON】metric regression mae
  • 【VISUAL Csharp】Enumerate network resources
  • 【VISUAL Csharp】File Properties
  • 【Visual Studio VB NET】Clear Saved Passwords
  • 【Visual Studio VB NET】Swap mouse button
  • 【Visual Studio VB NET】System Properties Remote
  • 【Visual Studio Visual Csharp】Get computer name
  • 【Visual Studio Visual Csharp】Get Disk Free Space
  • 【Visual Studio Visual Csharp】Get processor type
  • 【Visual Studio Visual Csharp】IP Address
  • 【VISUAL VB NET】Delete Form Data
  • 【VISUAL VB NET】Delete History
  • 【VISUAL VB NET】Hibernate
  • 【VISUAL VB NET】Keyboard Properties
  • 【VISUAL VB NET】Sound
  • 【VISUAL VB NET】Tray Icon
  • 【VISUAL VB NET】Web Browser
  • 【Vuejs】 table implements adding and deleting
  • 【VUEJS】seamless carousel effect Marquee using transition

Blog Archive

  • October 2023 (25)
  • September 2023 (1209)
  • August 2023 (1224)
  • July 2023 (1259)
  • June 2023 (1245)
  • May 2023 (1194)
  • April 2023 (1137)
  • March 2023 (1163)
  • February 2023 (1107)
  • January 2023 (1313)
  • December 2022 (1358)
  • November 2022 (1353)
  • October 2022 (1300)
  • September 2022 (1208)
  • August 2022 (1279)
  • July 2022 (1228)
  • June 2022 (1164)
  • May 2022 (1176)
  • April 2022 (1184)
  • March 2022 (1337)
  • February 2022 (1232)
  • January 2022 (1321)
  • December 2021 (1932)
  • November 2021 (3065)
  • October 2021 (3186)
  • September 2021 (3078)
  • August 2021 (3175)
  • July 2021 (3198)
  • June 2021 (3136)
  • May 2021 (1856)
Powered by Blogger.