Architecture
How it works
Each app reads your photos, stages a batch, and hands it to a small uploader that talks to Google Photos. This page follows one backup from start to finish.
The path
Your photos ──▶ the app ──── JSON over a pipe ────▶ gpmc bridge ──▶ gpmc ──▶ Google Photos
(albums, plans, exports a batch, (Python, (Google Photos
folders, records what Google bundled mobile API,
picked files) confirmed with the app) "Pixel XL")
The app is native on each platform (SwiftUI, WinUI 3, Compose). The uploading is done by gpmc (by xob0t), an open-source client for the API Google Photos' own mobile app uses. All three apps share one bridge script, Bridge/gpmc_bridge.py, so the upload logic has a single source of truth.
One backup, step by step
- Plan. On a Mac the app reads the selected albums through PhotoKit. Each item Google has not confirmed yet is uploaded once, even if it sits in several albums. Your own albums go first, so a photo lands straight in its Google album, then smart albums, then everything else.
- Export. For each batch the app writes the version Photos shows (the edited rendition if there is one, otherwise the original) into a private staging folder, downloading originals from iCloud first if needed. While one batch uploads, the next is prepared, up to a limit on disk, so the network does not wait on the library. On Android the app streams the picked files into private cache files and hashes them in batches.
- Upload. One bridge process serves the whole run. It hands each batch to gpmc, several files at once. gpmc hashes each file and asks Google whether it already has those bytes. Files Google has are reported as already backed up; the rest are uploaded, and Google returns a media key for each one.
- Albums. If album mirroring is on, an album with the same name is created by its first batch, and later batches and runs add to it.
- Record. The app saves each media key as soon as Google confirms it, and deletes the staging copies. A backup counts as done only on a confirmed media key.
Because Google's hash check decides what is new, resetting the app's history never uploads anything twice. And because only confirmed keys are recorded, an interrupted run loses nothing: the next one carries on.
The gpmc bridge
The bridge is the boundary between the native app and gpmc. The app writes one JSON request per line to the bridge's standard input, and the bridge answers with one JSON event per line on its standard output, with logs on standard error. On desktop one bridge process lives for the whole run, and it keeps its connections to Google open between files and batches. The Google credential reaches it over that pipe, never in a command line or an environment variable, where other programs of yours could read it. On Android the same script runs inside the app through an embedded Python.
Quality is a choice of two flags passed to gpmc for every upload, whatever the number of parallel uploads. Original quality is saver=False, use_quota=False and presents the upload as coming from a Pixel XL phone; Storage saver is a lower-quality option; and Original quality that counts against storage keeps the original but is charged to your storage. Tests check these flags on every path. Only Google decides what counts against your storage.
How sign-in works
The sign-in follows gotohp, another project by xob0t.
- The app shows Google's Embedded Setup page, the one Android's setup wizard shows, inside a web view with a throwaway session. After you choose I agree, Google leaves a single-use
oauth_tokencookie. - The app sends that cookie to Google's Android auth endpoint, as Google Play services would, for a newly generated Android device ID. Google returns a long-lived master token for that device.
- The app builds the request Google Photos for Android would make with that token, which is gpmc's
auth_data, and checks it with Google Photos before storing it.
Only the resulting auth_data is kept, in your system's protected storage. It works like a password.
Retries, rate limits and parallel uploads
- Retries. A failure is classified from Google's answer. Timeouts, HTTP 5xx and network errors are retried, three attempts in all, after 1 s and then 2 s. Other 4xx answers are permanent and not retried. The next run gives a failed item fresh attempts.
- HTTP 429. When Google says slow down, every upload waits, not only the one that hit it. The wait starts at 60 s, doubles while Google keeps refusing, and is capped at 10 minutes. After five holds in a row with nothing getting through, the run ends as failed instead of waiting forever.
- Parallel uploads. Automatic mode starts at 4 and steps up to 32 while each step is at least 10% faster, and steps back when Google pushes back or requests fail. A chosen number stays fixed.
- Conditions. On the Mac, automatic runs wait for a metered network, Low Data Mode, Low Power Mode or battery power if you have asked for that. Runs you start yourself go ahead.
What is stored where
| What | Mac | Windows | Android |
|---|---|---|---|
| Google credential | Login Keychain, this device only, after first unlock | Encrypted with DPAPI for your Windows account | AES-GCM with a non-exportable Android Keystore key, outside Android's backup |
| Backup record (media keys, album links) | JSON files in ~/Library/Application Support/io.github.ayush5harma.PhotosBackup/, one per account | %LOCALAPPDATA%\GooglePhotosBackup | A durable queue in the app's private, non-backed-up storage |
| Settings | The app's preferences | %LOCALAPPDATA%\GooglePhotosBackup | The app's private storage |
| Run history and timeline | The same folder: 40 runs, and 400 events no older than 14 days, with secrets removed | The same folder | Activity screen, cleared on disconnect |
| Staged upload copies | Caches, deleted after each batch | Folder backups read your files in place. Device and iCloud imports are staged in folders under the same root | Private cache, deleted after each batch and at start-up |
| Logs | Logs/bridge.log beside the record, rotated | Not documented separately | Python logging is switched off so credentials never reach the system log |
Nothing is stored on a server run by this project. There is none.
Read more
The code-level view is in ARCHITECTURE.md, every setting and its default in REFERENCE.md, and the bridge's line protocol in the docstring at the top of Bridge/gpmc_bridge.py.