# How do I export Apple Health data to my Mac automatically?

Source: https://healthsql.app/export-apple-health-automatically · Updated 2026-11-30

Install HealthSQL on your iPhone and make its one $7.99 purchase: Health then wakes the app when there is new data, the app writes it to your iCloud Drive, and the `healthsql` command on your Mac reads it into a SQLite database. One limit no app can remove: iOS does not let apps read Health while the iPhone is locked, so new data moves after you next unlock it.

HealthSQL is an iPhone app and a command-line tool that copy your whole Apple Health record into a local SQLite database on your computer, so AI agents can query it with SQL or MCP.

## How the automatic export works

1. **Health wakes the app.** The app asks Health to wake it for new workouts, sleep, heart rate variability, weight and VO2 max as they arrive, and at most once an hour for heart rate, steps and active energy. Apple sets that hourly limit for some types, steps among them ([Apple, background delivery](https://developer.apple.com/documentation/healthkit/hkhealthstore/enablebackgrounddelivery(for:frequency:withcompletion:))).
2. **The app writes what is new.** Each run picks up where the last one stopped: records of every type added or deleted since then, and Health's new daily totals, into the app's folder in your iCloud Drive.
3. **iCloud Drive brings the files to your Mac.** Nothing to schedule there.
4. **The command reads them when you ask.** Every `healthsql` command, and every MCP call, first reads any new files. Each answer carries `phone_synced`, the time of the iPhone's last export.

Without the purchase, the full export is free and runs each time you open the app.

## What automatic means on iOS

Apple's documentation says the device encrypts the Health store when the user locks it, so an app "may not be able to read data from the store when it runs in the background" ([Apple](https://developer.apple.com/documentation/healthkit/protecting-user-privacy)). In practice:

- **Sleep** recorded overnight reaches your Mac after you unlock the phone in the morning.
- **A workout** reaches it soon after the Watch saves it to the phone, if the phone is unlocked then, or after the next unlock.
- **Steps and heart rate** wake the app at most once an hour, and only while the phone is unlocked. They also travel with any other export.

If the phone has not exported for more than 3 days, `healthsql` says so in a `problem` line: "The iPhone last synced N days ago. Open HealthSQL on the iPhone; it can only read Health while the phone is unlocked." More in [what automatic can honestly mean on iOS](https://healthsql.app/blog/automatic-apple-health-export-ios).

## Other ways to export automatically

- **Health Auto Export** has automations that write to iCloud Drive, Google Drive, Dropbox, a REST API, Home Assistant and more, and a Sync to Mac for its Mac app, all on its Premium tier. Its help pages say the same iOS limit applies: the device must be unlocked ([iCloud Drive automation](https://help.healthyapps.dev/en/health-auto-export/automations/icloud-drive), [Sync to Mac](https://help.healthyapps.dev/en/health-auto-export/sync-to-mac), as of November 2026). It is the better choice for CSV files, dashboards or Home Assistant. [The full comparison](https://healthsql.app/vs/health-auto-export).
- **Apple's Export All Health Data** is manual: an XML file you make and move by hand each time ([Apple](https://support.apple.com/guide/iphone/share-your-health-data-iph5ede58c3d/ios)).

HealthSQL is for one job: a complete, current copy of your record on your Mac, as a database your AI agents can query.

## Questions

### Does the app have to be open?

With the purchase, no: Health wakes it. Without it, the export runs while the app is open.

### Does it export while my iPhone is locked?

No. iOS keeps Health data locked while the phone is locked, for every app. The export runs after the next unlock.

### Does my Mac have to be on?

Not for the export. The files wait in iCloud Drive, and the Mac reads them the next time you or your agent asks.

### Is the first export automatic too?

The first export of a long history takes a few minutes; keep the app open until it shows a record count. After that, each export carries only what is new.
